mordernize pointers

This commit is contained in:
vaxerski 2022-06-30 15:44:26 +02:00
parent d1564299d2
commit 328b3fa4bc
17 changed files with 393 additions and 346 deletions

View file

@ -172,8 +172,8 @@ void CCompositor::cleanupExit() {
m_pLastFocus = nullptr; m_pLastFocus = nullptr;
m_pLastWindow = nullptr; m_pLastWindow = nullptr;
m_lWorkspaces.clear(); m_vWorkspaces.clear();
m_lWindows.clear(); m_vWindows.clear();
if (g_pXWaylandManager->m_sWLRXWayland) { if (g_pXWaylandManager->m_sWLRXWayland) {
wlr_xwayland_destroy(g_pXWaylandManager->m_sWLRXWayland); wlr_xwayland_destroy(g_pXWaylandManager->m_sWLRXWayland);
@ -269,9 +269,9 @@ void CCompositor::startCompositor() {
} }
SMonitor* CCompositor::getMonitorFromID(const int& id) { SMonitor* CCompositor::getMonitorFromID(const int& id) {
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
if (m.ID == (uint64_t)id) { if (m->ID == (uint64_t)id) {
return &m; return m.get();
} }
} }
@ -279,9 +279,9 @@ SMonitor* CCompositor::getMonitorFromID(const int& id) {
} }
SMonitor* CCompositor::getMonitorFromName(const std::string& name) { SMonitor* CCompositor::getMonitorFromName(const std::string& name) {
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
if (m.szName == name) { if (m->szName == name) {
return &m; return m.get();
} }
} }
@ -301,18 +301,18 @@ SMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
float bestDistance = 0.f; float bestDistance = 0.f;
SMonitor* pBestMon = nullptr; SMonitor* pBestMon = nullptr;
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
float dist = vecToRectDistanceSquared(point, m.vecPosition, m.vecPosition + m.vecSize); float dist = vecToRectDistanceSquared(point, m->vecPosition, m->vecPosition + m->vecSize);
if (dist < bestDistance || !pBestMon) { if (dist < bestDistance || !pBestMon) {
bestDistance = dist; bestDistance = dist;
pBestMon = &m; pBestMon = m.get();
} }
} }
if (!pBestMon) { // ????? if (!pBestMon) { // ?????
Debug::log(WARN, "getMonitorFromVector no close mon???"); Debug::log(WARN, "getMonitorFromVector no close mon???");
return &m_lMonitors.front(); return m_vMonitors.front().get();
} }
return pBestMon; return pBestMon;
@ -322,13 +322,35 @@ SMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
} }
void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) { void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) {
if (windowExists(pWindow) && !pWindow->m_bFadingOut) if (windowExists(pWindow) && !pWindow->m_bFadingOut){
m_lWindows.remove(*pWindow); if (pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) {
m_dUnmanagedX11Windows.erase(std::remove_if(m_dUnmanagedX11Windows.begin(), m_dUnmanagedX11Windows.end(), [&](std::unique_ptr<CWindow>& el) { return el.get() == pWindow; }));
}
// if X11, also check its children
// and delete any needed
if (pWindow->m_bIsX11) {
for (auto& w : m_vWindows) {
if (!w->m_bIsX11)
continue;
if (w->m_pX11Parent == pWindow)
m_vWindows.erase(std::remove_if(m_vWindows.begin(), m_vWindows.end(), [&](std::unique_ptr<CWindow>& el) { return el.get() == w.get(); }));
}
for (auto& w : m_dUnmanagedX11Windows) {
if (w->m_pX11Parent == pWindow)
m_dUnmanagedX11Windows.erase(std::remove_if(m_dUnmanagedX11Windows.begin(), m_dUnmanagedX11Windows.end(), [&](std::unique_ptr<CWindow>& el) { return el.get() == w.get(); }));
}
}
m_vWindows.erase(std::remove_if(m_vWindows.begin(), m_vWindows.end(), [&](std::unique_ptr<CWindow>& el) { return el.get() == pWindow; }));
}
} }
bool CCompositor::windowExists(CWindow* pWindow) { bool CCompositor::windowExists(CWindow* pWindow) {
for (auto& w : m_lWindows) { // TODO: get rid of unmanaged X11? for (auto& w : m_vWindows) {
if (&w == pWindow) if (w.get() == pWindow)
return true; return true;
} }
@ -339,24 +361,24 @@ CWindow* CCompositor::vectorToWindow(const Vector2D& pos) {
const auto PMONITOR = getMonitorFromVector(pos); const auto PMONITOR = getMonitorFromVector(pos);
if (PMONITOR->specialWorkspaceOpen) { if (PMONITOR->specialWorkspaceOpen) {
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
wlr_box box = {w.m_vRealPosition.vec().x, w.m_vRealPosition.vec().y, w.m_vRealSize.vec().x, w.m_vRealSize.vec().y};
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, pos.x, pos.y) && w.m_bIsMapped && !w.m_bIsFloating && !w.m_bHidden)
return &w;
}
}
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) {
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
if (wlr_box_contains_point(&box, pos.x, pos.y) && w->m_bIsMapped && w->m_bIsFloating && isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, pos.x, pos.y) && w->m_bIsMapped && !w->m_bIsFloating && !w->m_bHidden)
return &(*w); return w.get();
}
} }
for (auto& w : m_lWindows) { // first loop over floating cuz they're above, m_vWindows should be sorted bottom->top, for tiled it doesn't matter.
wlr_box box = {w.m_vRealPosition.vec().x, w.m_vRealPosition.vec().y, w.m_vRealSize.vec().x, w.m_vRealSize.vec().y}; for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
if (wlr_box_contains_point(&box, pos.x, pos.y) && w.m_bIsMapped && !w.m_bIsFloating && PMONITOR->activeWorkspace == w.m_iWorkspaceID && !w.m_bHidden) wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
return &w; if (wlr_box_contains_point(&box, pos.x, pos.y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bHidden)
return w->get();
}
for (auto& w : m_vWindows) {
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
if (wlr_box_contains_point(&box, pos.x, pos.y) && w->m_bIsMapped && !w->m_bIsFloating && PMONITOR->activeWorkspace == w->m_iWorkspaceID && !w->m_bHidden)
return w.get();
} }
return nullptr; return nullptr;
@ -366,17 +388,17 @@ CWindow* CCompositor::vectorToWindowTiled(const Vector2D& pos) {
const auto PMONITOR = getMonitorFromVector(pos); const auto PMONITOR = getMonitorFromVector(pos);
if (PMONITOR->specialWorkspaceOpen) { if (PMONITOR->specialWorkspaceOpen) {
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y}; wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, pos.x, pos.y) && !w.m_bIsFloating && !w.m_bHidden) if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, pos.x, pos.y) && !w->m_bIsFloating && !w->m_bHidden)
return &w; return w.get();
} }
} }
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y}; wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
if (w.m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w.m_iWorkspaceID == PMONITOR->activeWorkspace && !w.m_bIsFloating && !w.m_bHidden) if (w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->m_bIsFloating && !w->m_bHidden)
return &w; return w.get();
} }
return nullptr; return nullptr;
@ -387,24 +409,24 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
// special workspace // special workspace
if (PMONITOR->specialWorkspaceOpen) { if (PMONITOR->specialWorkspaceOpen) {
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y}; wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID && w.m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w.m_bHidden) if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w->m_bHidden)
return &w; return w.get();
} }
} }
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter. // first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) { for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
if (w->m_bIsFloating && w->m_bIsMapped && wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) if ((*w)->m_bIsFloating && (*w)->m_bIsMapped && wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bHidden)
return &(*w); return w->get();
} }
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y}; wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
if (!w.m_bIsFloating && w.m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w.m_iWorkspaceID == PMONITOR->activeWorkspace && !w.m_bHidden) if (!w->m_bIsFloating && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->m_bHidden)
return &w; return w.get();
} }
return nullptr; return nullptr;
@ -414,34 +436,34 @@ CWindow* CCompositor::windowFromCursor() {
const auto PMONITOR = getMonitorFromCursor(); const auto PMONITOR = getMonitorFromCursor();
if (PMONITOR->specialWorkspaceOpen) { if (PMONITOR->specialWorkspaceOpen) {
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y}; wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w.m_bIsMapped) if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w->m_bIsMapped)
return &w; return w.get();
} }
} }
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter. // first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) { for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w->m_bIsMapped && w->m_bIsFloating && isWorkspaceVisible(w->m_iWorkspaceID)) if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID))
return &(*w); return w->get();
} }
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
wlr_box box = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y}; wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w.m_bIsMapped && w.m_iWorkspaceID == PMONITOR->activeWorkspace) if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w->m_bIsMapped && w->m_iWorkspaceID == PMONITOR->activeWorkspace)
return &w; return w.get();
} }
return nullptr; return nullptr;
} }
CWindow* CCompositor::windowFloatingFromCursor() { CWindow* CCompositor::windowFloatingFromCursor() {
for (auto w = m_lWindows.rbegin(); w != m_lWindows.rend(); w++) { for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w->m_bIsMapped && w->m_bIsFloating && isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bHidden)
return &(*w); return w->get();
} }
return nullptr; return nullptr;
@ -480,9 +502,9 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW
} }
SMonitor* CCompositor::getMonitorFromOutput(wlr_output* out) { SMonitor* CCompositor::getMonitorFromOutput(wlr_output* out) {
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
if (m.output == out) { if (m->output == out) {
return &m; return m.get();
} }
} }
@ -595,9 +617,9 @@ bool CCompositor::windowValidMapped(CWindow* pWindow) {
} }
CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) { CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) {
for (auto& p : m_lXDGPopups) { for (auto& p : m_vXDGPopups) {
if (p.popup == popup) if (p->popup == popup)
return p.parentWindow; return p->parentWindow;
} }
return nullptr; return nullptr;
@ -618,29 +640,29 @@ wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::list<SL
} }
CWindow* CCompositor::getWindowFromSurface(wlr_surface* pSurface) { CWindow* CCompositor::getWindowFromSurface(wlr_surface* pSurface) {
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (g_pXWaylandManager->getWindowSurface(&w) == pSurface) if (g_pXWaylandManager->getWindowSurface(w.get()) == pSurface)
return &w; return w.get();
} }
return nullptr; return nullptr;
} }
CWindow* CCompositor::getFullscreenWindowOnWorkspace(const int& ID) { CWindow* CCompositor::getFullscreenWindowOnWorkspace(const int& ID) {
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (w.m_iWorkspaceID == ID && w.m_bIsFullscreen) if (w->m_iWorkspaceID == ID && w->m_bIsFullscreen)
return &w; return w.get();
} }
return nullptr; return nullptr;
} }
bool CCompositor::isWorkspaceVisible(const int& w) { bool CCompositor::isWorkspaceVisible(const int& w) {
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
if (m.activeWorkspace == w) if (m->activeWorkspace == w)
return true; return true;
if (m.specialWorkspaceOpen && w == SPECIAL_WORKSPACE_ID) if (m->specialWorkspaceOpen && w == SPECIAL_WORKSPACE_ID)
return true; return true;
} }
@ -648,34 +670,34 @@ bool CCompositor::isWorkspaceVisible(const int& w) {
} }
CWorkspace* CCompositor::getWorkspaceByID(const int& id) { CWorkspace* CCompositor::getWorkspaceByID(const int& id) {
for (auto& w : m_lWorkspaces) { for (auto& w : m_vWorkspaces) {
if (w.m_iID == id) if (w->m_iID == id)
return &w; return w.get();
} }
return nullptr; return nullptr;
} }
void CCompositor::sanityCheckWorkspaces() { void CCompositor::sanityCheckWorkspaces() {
for (auto it = m_lWorkspaces.begin(); it != m_lWorkspaces.end(); ++it) { for (auto it = m_vWorkspaces.begin(); it != m_vWorkspaces.end(); ++it) {
if ((getWindowsOnWorkspace(it->m_iID) == 0 && !isWorkspaceVisible(it->m_iID))) { if ((getWindowsOnWorkspace((*it)->m_iID) == 0 && !isWorkspaceVisible((*it)->m_iID))) {
it = m_lWorkspaces.erase(it); it = m_vWorkspaces.erase(it);
} }
if (it->m_iID == SPECIAL_WORKSPACE_ID && getWindowsOnWorkspace(it->m_iID) == 0) { if ((*it)->m_iID == SPECIAL_WORKSPACE_ID && getWindowsOnWorkspace((*it)->m_iID) == 0) {
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
m.specialWorkspaceOpen = false; m->specialWorkspaceOpen = false;
} }
it = m_lWorkspaces.erase(it); it = m_vWorkspaces.erase(it);
} }
} }
} }
int CCompositor::getWindowsOnWorkspace(const int& id) { int CCompositor::getWindowsOnWorkspace(const int& id) {
int no = 0; int no = 0;
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (w.m_iWorkspaceID == id && w.m_bIsMapped) if (w->m_iWorkspaceID == id && w->m_bIsMapped)
no++; no++;
} }
@ -683,9 +705,9 @@ int CCompositor::getWindowsOnWorkspace(const int& id) {
} }
CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) { CWindow* CCompositor::getFirstWindowOnWorkspace(const int& id) {
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (w.m_iWorkspaceID == id) if (w->m_iWorkspaceID == id)
return &w; return w.get();
} }
return nullptr; return nullptr;
@ -699,16 +721,16 @@ void CCompositor::fixXWaylandWindowsOnWorkspace(const int& id) {
if (!PWORKSPACE) if (!PWORKSPACE)
return; return;
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (w.m_iWorkspaceID == id) { if (w->m_iWorkspaceID == id) {
// moveXWaylandWindow only moves XWayland windows // moveXWaylandWindow only moves XWayland windows
// so there is no need to check here // so there is no need to check here
// if the window is XWayland or not. // if the window is XWayland or not.
if (ISVISIBLE && (!PWORKSPACE->m_bHasFullscreenWindow || w.m_bIsFullscreen)) if (ISVISIBLE && (!PWORKSPACE->m_bHasFullscreenWindow || w->m_bIsFullscreen))
g_pXWaylandManager->moveXWaylandWindow(&w, w.m_vRealPosition.vec()); g_pXWaylandManager->moveXWaylandWindow(w.get(), w->m_vRealPosition.vec());
else else
g_pXWaylandManager->moveXWaylandWindow(&w, Vector2D(42069,42069)); g_pXWaylandManager->moveXWaylandWindow(w.get(), Vector2D(42069,42069));
} }
} }
} }
@ -733,16 +755,16 @@ void CCompositor::moveWindowToTop(CWindow* pWindow) {
if (!windowValidMapped(pWindow)) if (!windowValidMapped(pWindow))
return; return;
for (auto it = m_lWindows.begin(); it != m_lWindows.end(); ++it) { for (auto it = m_vWindows.begin(); it != m_vWindows.end(); ++it) {
if (&(*it) == pWindow) { if (it->get() == pWindow) {
m_lWindows.splice(m_lWindows.end(), m_lWindows, it); std::rotate(it, it + 1, m_vWindows.end());
break; break;
} }
} }
} }
void CCompositor::cleanupFadingOut() { void CCompositor::cleanupFadingOut() {
for (auto& w : m_lWindowsFadingOut) { for (auto& w : m_vWindowsFadingOut) {
bool valid = windowExists(w); bool valid = windowExists(w);
@ -752,18 +774,18 @@ void CCompositor::cleanupFadingOut() {
g_pHyprOpenGL->m_mWindowFramebuffers[w].release(); g_pHyprOpenGL->m_mWindowFramebuffers[w].release();
g_pHyprOpenGL->m_mWindowFramebuffers.erase(w); g_pHyprOpenGL->m_mWindowFramebuffers.erase(w);
m_lWindows.remove(*w); removeWindowFromVectorSafe(w);
m_lWindowsFadingOut.remove(w); m_vWindowsFadingOut.erase(std::remove(m_vWindowsFadingOut.begin(), m_vWindowsFadingOut.end(), w));
Debug::log(LOG, "Cleanup: destroyed a window"); Debug::log(LOG, "Cleanup: destroyed a window");
return; return;
} }
} }
for (auto& ls : m_lSurfacesFadingOut) { for (auto& ls : m_vSurfacesFadingOut) {
if (ls->fadingOut && ls->readyToDelete && !ls->alpha.isBeingAnimated()) { if (ls->fadingOut && ls->readyToDelete && !ls->alpha.isBeingAnimated()) {
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
for (auto& lsl : m.m_aLayerSurfaceLists) { for (auto& lsl : m->m_aLayerSurfaceLists) {
lsl.remove(ls); lsl.remove(ls);
} }
} }
@ -772,7 +794,7 @@ void CCompositor::cleanupFadingOut() {
g_pHyprOpenGL->m_mLayerFramebuffers.erase(ls); g_pHyprOpenGL->m_mLayerFramebuffers.erase(ls);
delete ls; delete ls;
m_lSurfacesFadingOut.remove(ls); m_vSurfacesFadingOut.erase(std::remove(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), ls));
Debug::log(LOG, "Cleanup: destroyed a layersurface"); Debug::log(LOG, "Cleanup: destroyed a layersurface");
@ -791,11 +813,11 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
auto longestIntersect = -1; auto longestIntersect = -1;
CWindow* longestIntersectWindow = nullptr; CWindow* longestIntersectWindow = nullptr;
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (&w == pWindow || !windowValidMapped(&w) || w.m_bIsFloating || !isWorkspaceVisible(w.m_iWorkspaceID)) if (w.get() == pWindow || !w->m_bIsMapped || w->m_bHidden || w->m_bIsFloating || !isWorkspaceVisible(w->m_iWorkspaceID))
continue; continue;
const auto BWINDOWIDEALBB = w.getWindowIdealBoundingBoxIgnoreReserved(); const auto BWINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved();
const auto POSB = Vector2D(BWINDOWIDEALBB.x, BWINDOWIDEALBB.y); const auto POSB = Vector2D(BWINDOWIDEALBB.x, BWINDOWIDEALBB.y);
const auto SIZEB = Vector2D(BWINDOWIDEALBB.width, BWINDOWIDEALBB.height); const auto SIZEB = Vector2D(BWINDOWIDEALBB.width, BWINDOWIDEALBB.height);
@ -806,7 +828,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
const auto INTERSECTLEN = std::max((double)0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); const auto INTERSECTLEN = std::max((double)0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectWindow = &w; longestIntersectWindow = w.get();
} }
} }
break; break;
@ -815,7 +837,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
const auto INTERSECTLEN = std::max((double)0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); const auto INTERSECTLEN = std::max((double)0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectWindow = &w; longestIntersectWindow = w.get();
} }
} }
break; break;
@ -825,7 +847,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
const auto INTERSECTLEN = std::max((double)0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); const auto INTERSECTLEN = std::max((double)0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectWindow = &w; longestIntersectWindow = w.get();
} }
} }
break; break;
@ -835,7 +857,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
const auto INTERSECTLEN = std::max((double)0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); const auto INTERSECTLEN = std::max((double)0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectWindow = &w; longestIntersectWindow = w.get();
} }
} }
break; break;
@ -849,30 +871,30 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
} }
void CCompositor::deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude) { void CCompositor::deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude) {
for (auto& w : m_lWorkspaces) { for (auto& w : m_vWorkspaces) {
if (w.m_pWlrHandle && w.m_pWlrHandle != exclude) if (w->m_pWlrHandle && w->m_pWlrHandle != exclude)
w.setActive(false); w->setActive(false);
} }
} }
CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) { CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) {
bool gotToWindow = false; bool gotToWindow = false;
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (&w != pWindow && !gotToWindow) if (w.get() != pWindow && !gotToWindow)
continue; continue;
if (&w == pWindow) { if (w.get() == pWindow) {
gotToWindow = true; gotToWindow = true;
continue; continue;
} }
if (w.m_iWorkspaceID == pWindow->m_iWorkspaceID && windowValidMapped(&w)) if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden)
return &w; return w.get();
} }
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (&w != pWindow && w.m_iWorkspaceID == pWindow->m_iWorkspaceID && windowValidMapped(&w)) if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->m_bHidden)
return &w; return w.get();
} }
return nullptr; return nullptr;
@ -880,18 +902,18 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow) {
int CCompositor::getNextAvailableNamedWorkspace() { int CCompositor::getNextAvailableNamedWorkspace() {
int lowest = -1337 + 1; int lowest = -1337 + 1;
for (auto& w : m_lWorkspaces) { for (auto& w : m_vWorkspaces) {
if (w.m_iID < -1 && w.m_iID < lowest) if (w->m_iID < -1 && w->m_iID < lowest)
lowest = w.m_iID; lowest = w->m_iID;
} }
return lowest - 1; return lowest - 1;
} }
CWorkspace* CCompositor::getWorkspaceByName(const std::string& name) { CWorkspace* CCompositor::getWorkspaceByName(const std::string& name) {
for (auto& w : m_lWorkspaces) { for (auto& w : m_vWorkspaces) {
if (w.m_szName == name) if (w->m_szName == name)
return &w; return w.get();
} }
return nullptr; return nullptr;
@ -913,8 +935,8 @@ CWorkspace* CCompositor::getWorkspaceByString(const std::string& str) {
} }
bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) { bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) {
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
if (VECINRECT(point, m.vecPosition.x, m.vecPosition.y, m.vecSize.x + m.vecPosition.x, m.vecSize.y + m.vecPosition.y)) if (VECINRECT(point, m->vecPosition.x, m->vecPosition.y, m->vecSize.x + m->vecPosition.x, m->vecSize.y + m->vecPosition.y))
return true; return true;
} }
@ -927,12 +949,12 @@ CWindow* CCompositor::getConstraintWindow(SMouse* pMouse) {
const auto PSURFACE = pMouse->currentConstraint->surface; const auto PSURFACE = pMouse->currentConstraint->surface;
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (PSURFACE == g_pXWaylandManager->getWindowSurface(&w)) { if (PSURFACE == g_pXWaylandManager->getWindowSurface(w.get())) {
if (!w.m_bIsX11 && !windowValidMapped(&w)) if (!w->m_bIsX11 && w->m_bIsMapped && !w->m_bHidden)
continue; continue;
return &w; return w.get();
} }
} }
@ -946,19 +968,19 @@ SMonitor* CCompositor::getMonitorInDirection(const char& dir) {
auto longestIntersect = -1; auto longestIntersect = -1;
SMonitor* longestIntersectMonitor = nullptr; SMonitor* longestIntersectMonitor = nullptr;
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
if (&m == m_pLastMonitor) if (m.get() == m_pLastMonitor)
continue; continue;
const auto POSB = m.vecPosition; const auto POSB = m->vecPosition;
const auto SIZEB = m.vecSize; const auto SIZEB = m->vecSize;
switch (dir) { switch (dir) {
case 'l': case 'l':
if (STICKS(POSA.x, POSB.x + SIZEB.x)) { if (STICKS(POSA.x, POSB.x + SIZEB.x)) {
const auto INTERSECTLEN = std::max((double)0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); const auto INTERSECTLEN = std::max((double)0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectMonitor = &m; longestIntersectMonitor = m.get();
} }
} }
break; break;
@ -967,7 +989,7 @@ SMonitor* CCompositor::getMonitorInDirection(const char& dir) {
const auto INTERSECTLEN = std::max((double)0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); const auto INTERSECTLEN = std::max((double)0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectMonitor = &m; longestIntersectMonitor = m.get();
} }
} }
break; break;
@ -977,7 +999,7 @@ SMonitor* CCompositor::getMonitorInDirection(const char& dir) {
const auto INTERSECTLEN = std::max((double)0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); const auto INTERSECTLEN = std::max((double)0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectMonitor = &m; longestIntersectMonitor = m.get();
} }
} }
break; break;
@ -987,7 +1009,7 @@ SMonitor* CCompositor::getMonitorInDirection(const char& dir) {
const auto INTERSECTLEN = std::max((double)0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); const auto INTERSECTLEN = std::max((double)0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectMonitor = &m; longestIntersectMonitor = m.get();
} }
} }
break; break;
@ -1001,11 +1023,11 @@ SMonitor* CCompositor::getMonitorInDirection(const char& dir) {
} }
void CCompositor::updateAllWindowsBorders() { void CCompositor::updateAllWindowsBorders() {
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (!w.m_bIsMapped) if (!w->m_bIsMapped)
continue; continue;
updateWindowBorderColor(&w); updateWindowBorderColor(w.get());
} }
} }
@ -1030,9 +1052,9 @@ void CCompositor::moveWindowToWorkspace(CWindow* pWindow, const std::string& wor
int CCompositor::getNextAvailableMonitorID() { int CCompositor::getNextAvailableMonitorID() {
int64_t topID = -1; int64_t topID = -1;
for (auto& m : m_lMonitors) { for (auto& m : m_vMonitors) {
if ((int64_t)m.ID > topID) if ((int64_t)m->ID > topID)
topID = m.ID; topID = m->ID;
} }
return topID + 1; return topID + 1;
@ -1053,9 +1075,9 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, SMonitor* pMoni
// fix old mon // fix old mon
int nextWorkspaceOnMonitorID = -1; int nextWorkspaceOnMonitorID = -1;
for (auto& w : m_lWorkspaces) { for (auto& w : m_vWorkspaces) {
if (w.m_iMonitorID == POLDMON->ID && w.m_iID != pWorkspace->m_iID) { if (w->m_iMonitorID == POLDMON->ID && w->m_iID != pWorkspace->m_iID) {
nextWorkspaceOnMonitorID = w.m_iID; nextWorkspaceOnMonitorID = w->m_iID;
break; break;
} }
} }
@ -1079,9 +1101,9 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, SMonitor* pMoni
pWorkspace->m_iMonitorID = pMonitor->ID; pWorkspace->m_iMonitorID = pMonitor->ID;
pWorkspace->moveToMonitor(pMonitor->ID); pWorkspace->moveToMonitor(pMonitor->ID);
for (auto& w : m_lWindows) { for (auto& w : m_vWindows) {
if (w.m_iWorkspaceID == pWorkspace->m_iID) if (w->m_iWorkspaceID == pWorkspace->m_iID)
w.m_iMonitorID = pMonitor->ID; w->m_iMonitorID = pMonitor->ID;
} }
if (SWITCHINGISACTIVE) { // if it was active, preserve its' status. If it wasn't, don't. if (SWITCHINGISACTIVE) { // if it was active, preserve its' status. If it wasn't, don't.
@ -1108,12 +1130,12 @@ bool CCompositor::workspaceIDOutOfBounds(const int& id) {
int lowestID = 99999; int lowestID = 99999;
int highestID = -99999; int highestID = -99999;
for (auto& w : m_lWorkspaces) { for (auto& w : m_vWorkspaces) {
if (w.m_iID < lowestID) if (w->m_iID < lowestID)
lowestID = w.m_iID; lowestID = w->m_iID;
if (w.m_iID > highestID) if (w->m_iID > highestID)
highestID = w.m_iID; highestID = w->m_iID;
} }
return std::clamp(id, lowestID, highestID) != id; return std::clamp(id, lowestID, highestID) != id;
@ -1127,8 +1149,33 @@ void CCompositor::setWindowFullscreen(CWindow* pWindow, bool on, eFullscreenMode
g_pXWaylandManager->setWindowFullscreen(pWindow, pWindow->m_bIsFullscreen && mode == FULLSCREEN_FULL); g_pXWaylandManager->setWindowFullscreen(pWindow, pWindow->m_bIsFullscreen && mode == FULLSCREEN_FULL);
// make all windows on the same workspace under the fullscreen window // make all windows on the same workspace under the fullscreen window
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w.m_iWorkspaceID == pWindow->m_iWorkspaceID) if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID)
w.m_bCreatedOverFullscreen = false; w->m_bCreatedOverFullscreen = false;
} }
} }
void CCompositor::moveUnmanagedX11ToWindows(CWindow* pWindow) {
for (auto it = m_dUnmanagedX11Windows.begin(); it != m_dUnmanagedX11Windows.end(); it++) {
if (it->get() == pWindow) {
m_vWindows.emplace_back(std::move(*it));
m_dUnmanagedX11Windows.erase(it);
return;
}
}
}
CWindow* CCompositor::getX11Parent(CWindow* pWindow) {
if (!pWindow->m_bIsX11)
return nullptr;
for (auto& w : m_vWindows) {
if (!w->m_bIsX11)
continue;
if (w->m_uSurface.xwayland == pWindow->m_uSurface.xwayland->parent)
return w.get();
}
return nullptr;
}

View file

@ -67,13 +67,14 @@ public:
const char* m_szWLDisplaySocket; const char* m_szWLDisplaySocket;
std::string m_szInstanceSignature = ""; std::string m_szInstanceSignature = "";
std::list<SMonitor> m_lMonitors; std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
std::list<CWindow> m_lWindows; std::vector<std::unique_ptr<CWindow>> m_vWindows;
std::list<SXDGPopup> m_lXDGPopups; std::deque<std::unique_ptr<CWindow>> m_dUnmanagedX11Windows;
std::list<CWorkspace> m_lWorkspaces; std::vector<std::unique_ptr<SXDGPopup>> m_vXDGPopups;
std::list<SSubsurface> m_lSubsurfaces; std::vector<std::unique_ptr<CWorkspace>> m_vWorkspaces;
std::list<CWindow*> m_lWindowsFadingOut; std::vector<std::unique_ptr<SSubsurface>> m_vSubsurfaces;
std::list<SLayerSurface*> m_lSurfacesFadingOut; std::vector<CWindow*> m_vWindowsFadingOut;
std::vector<SLayerSurface*> m_vSurfacesFadingOut;
void startCompositor(); void startCompositor();
void cleanupExit(); void cleanupExit();
@ -134,6 +135,8 @@ public:
void moveWorkspaceToMonitor(CWorkspace*, SMonitor*); void moveWorkspaceToMonitor(CWorkspace*, SMonitor*);
bool workspaceIDOutOfBounds(const int&); bool workspaceIDOutOfBounds(const int&);
void setWindowFullscreen(CWindow*, bool, eFullscreenMode); void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
void moveUnmanagedX11ToWindows(CWindow*);
CWindow* getX11Parent(CWindow*);
private: private:
void initAllSignals(); void initAllSignals();

View file

@ -67,6 +67,7 @@ public:
// XWayland stuff // XWayland stuff
bool m_bIsX11 = false; bool m_bIsX11 = false;
bool m_bMappedX11 = false; bool m_bMappedX11 = false;
CWindow* m_pX11Parent = nullptr;
uint64_t m_iX11Type = 0; uint64_t m_iX11Type = 0;
bool m_bIsModal = false; bool m_bIsModal = false;
bool m_bX11DoesntWantBorders = false; bool m_bX11DoesntWantBorders = false;

View file

@ -613,8 +613,8 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
parseError = ""; parseError = "";
// invalidate layouts jic // invalidate layouts jic
for (auto& m : g_pCompositor->m_lMonitors) for (auto& m : g_pCompositor->m_vMonitors)
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
// Update window border colors // Update window border colors
g_pCompositor->updateAllWindowsBorders(); g_pCompositor->updateAllWindowsBorders();
@ -774,8 +774,8 @@ void CConfigManager::loadConfigLoadVars() {
ifs.close(); ifs.close();
} }
for (auto& m : g_pCompositor->m_lMonitors) for (auto& m : g_pCompositor->m_vMonitors)
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
// Update the keyboard layout to the cfg'd one if this is not the first launch // Update the keyboard layout to the cfg'd one if this is not the first launch
if (!isFirstLaunch) if (!isFirstLaunch)
@ -810,8 +810,8 @@ void CConfigManager::loadConfigLoadVars() {
g_pCompositor->updateAllWindowsBorders(); g_pCompositor->updateAllWindowsBorders();
// Force the compositor to fully re-render all monitors // Force the compositor to fully re-render all monitors
for (auto& m : g_pCompositor->m_lMonitors) for (auto& m : g_pCompositor->m_vMonitors)
m.forceFullFrames = 2; m->forceFullFrames = 2;
} }
void CConfigManager::tick() { void CConfigManager::tick() {
@ -970,9 +970,9 @@ void CConfigManager::dispatchExecOnce() {
} }
void CConfigManager::performMonitorReload() { void CConfigManager::performMonitorReload() {
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
auto rule = getMonitorRuleFor(m.szName); auto rule = getMonitorRuleFor(m->szName);
g_pHyprRenderer->applyMonitorRule(&m, &rule); g_pHyprRenderer->applyMonitorRule(m.get(), &rule);
} }
m_bWantsMonitorReload = false; m_bWantsMonitorReload = false;

View file

@ -15,9 +15,9 @@
std::string monitorsRequest() { std::string monitorsRequest() {
std::string result = ""; std::string result = "";
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tactive workspace: %i (%s)\n\treserved: %i %i %i %i\n\tscale: %.2f\n\ttransform: %i\n\n", result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tactive workspace: %i (%s)\n\treserved: %i %i %i %i\n\tscale: %.2f\n\ttransform: %i\n\n",
m.szName.c_str(), m.ID, (int)m.vecPixelSize.x, (int)m.vecPixelSize.y, m.refreshRate, (int)m.vecPosition.x, (int)m.vecPosition.y, m.activeWorkspace, g_pCompositor->getWorkspaceByID(m.activeWorkspace)->m_szName.c_str(), (int)m.vecReservedTopLeft.x, (int)m.vecReservedTopLeft.y, (int)m.vecReservedBottomRight.x, (int)m.vecReservedBottomRight.y, m.scale, (int)m.transform); m->szName.c_str(), m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, m->activeWorkspace, g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName.c_str(), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform);
} }
return result; return result;
@ -25,10 +25,10 @@ std::string monitorsRequest() {
std::string clientsRequest() { std::string clientsRequest() {
std::string result = ""; std::string result = "";
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w.m_bIsMapped) { if (w->m_bIsMapped) {
result += getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\n", result += getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\n",
&w, w.m_szTitle.c_str(), (int)w.m_vRealPosition.vec().x, (int)w.m_vRealPosition.vec().y, (int)w.m_vRealSize.vec().x, (int)w.m_vRealSize.vec().y, w.m_iWorkspaceID, (w.m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w.m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w.m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w.m_iWorkspaceID)).c_str()), (int)w.m_bIsFloating, w.m_iMonitorID, g_pXWaylandManager->getAppIDClass(&w).c_str(), g_pXWaylandManager->getTitle(&w).c_str(), w.getPID()); &w, w->m_szTitle.c_str(), (int)w->m_vRealPosition.vec().x, (int)w->m_vRealPosition.vec().y, (int)w->m_vRealSize.vec().x, (int)w->m_vRealSize.vec().y, w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()), (int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w.get()).c_str(), g_pXWaylandManager->getTitle(w.get()).c_str(), w->getPID());
} }
} }
@ -37,9 +37,9 @@ std::string clientsRequest() {
std::string workspacesRequest() { std::string workspacesRequest() {
std::string result = ""; std::string result = "";
for (auto& w : g_pCompositor->m_lWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\n\n", result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\n\n",
w.m_iID, w.m_szName.c_str(), g_pCompositor->getMonitorFromID(w.m_iMonitorID)->szName.c_str(), g_pCompositor->getWindowsOnWorkspace(w.m_iID), (int)w.m_bHasFullscreenWindow); w->m_iID, w->m_szName.c_str(), g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName.c_str(), g_pCompositor->getWindowsOnWorkspace(w->m_iID), (int)w->m_bHasFullscreenWindow);
} }
return result; return result;
} }
@ -57,10 +57,10 @@ std::string activeWindowRequest() {
std::string layersRequest() { std::string layersRequest() {
std::string result = ""; std::string result = "";
for (auto& mon : g_pCompositor->m_lMonitors) { for (auto& mon : g_pCompositor->m_vMonitors) {
result += getFormat("Monitor %s:\n"); result += getFormat("Monitor %s:\n");
int layerLevel = 0; int layerLevel = 0;
for (auto& level : mon.m_aLayerSurfaceLists) { for (auto& level : mon->m_aLayerSurfaceLists) {
result += getFormat("\tLayer level %i:\n", layerLevel); result += getFormat("\tLayer level %i:\n", layerLevel);
for (auto& layer : level) { for (auto& layer : level) {

View file

@ -120,7 +120,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
yOffset += 11; yOffset += 11;
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox); g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
m_wbLastDrawnBox = {(int)g_pCompositor->m_lMonitors.front().vecPosition.x, (int)g_pCompositor->m_lMonitors.front().vecPosition.y + offset - 1, (int)maxX + 2, yOffset - offset + 2}; m_wbLastDrawnBox = {(int)g_pCompositor->m_vMonitors.front()->vecPosition.x, (int)g_pCompositor->m_vMonitors.front()->vecPosition.y + offset - 1, (int)maxX + 2, yOffset - offset + 2};
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox); g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
return yOffset - offset; return yOffset - offset;
@ -140,7 +140,7 @@ void CHyprDebugOverlay::frameData(SMonitor* pMonitor) {
void CHyprDebugOverlay::draw() { void CHyprDebugOverlay::draw() {
const auto PMONITOR = &g_pCompositor->m_lMonitors.front(); const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
if (!m_pCairoSurface || !m_pCairo) { if (!m_pCairoSurface || !m_pCairo) {
m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecSize.x, PMONITOR->vecSize.y); m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecSize.x, PMONITOR->vecSize.y);
@ -155,8 +155,8 @@ void CHyprDebugOverlay::draw() {
// draw the things // draw the things
int offsetY = 0; int offsetY = 0;
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
offsetY += m_mMonitorOverlays[&m].draw(offsetY); offsetY += m_mMonitorOverlays[m.get()].draw(offsetY);
offsetY += 5; // for padding between mons offsetY += 5; // for padding between mons
} }

View file

@ -36,7 +36,7 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
SLayerSurface* layerSurface = PMONITOR->m_aLayerSurfaceLists[WLRLAYERSURFACE->pending.layer].back(); SLayerSurface* layerSurface = PMONITOR->m_aLayerSurfaceLists[WLRLAYERSURFACE->pending.layer].back();
if (!WLRLAYERSURFACE->output) { if (!WLRLAYERSURFACE->output) {
WLRLAYERSURFACE->output = g_pCompositor->m_lMonitors.front().output; // TODO: current mon WLRLAYERSURFACE->output = g_pCompositor->m_vMonitors.front()->output; // TODO: current mon
} }
layerSurface->hyprListener_commitLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.commit, &Events::listener_commitLayerSurface, layerSurface, "layerSurface"); layerSurface->hyprListener_commitLayerSurface.initCallback(&WLRLAYERSURFACE->surface->events.commit, &Events::listener_commitLayerSurface, layerSurface, "layerSurface");
@ -145,7 +145,7 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
layersurface->fadingOut = true; layersurface->fadingOut = true;
g_pCompositor->m_lSurfacesFadingOut.push_back(layersurface); g_pCompositor->m_vSurfacesFadingOut.push_back(layersurface);
if (layersurface->layerSurface->mapped) if (layersurface->layerSurface->mapped)
layersurface->layerSurface->mapped = false; layersurface->layerSurface->mapped = false;

View file

@ -21,24 +21,24 @@ void Events::listener_change(wl_listener* listener, void* data) {
// layout got changed, let's update monitors. // layout got changed, let's update monitors.
const auto CONFIG = wlr_output_configuration_v1_create(); const auto CONFIG = wlr_output_configuration_v1_create();
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
const auto CONFIGHEAD = wlr_output_configuration_head_v1_create(CONFIG, m.output); const auto CONFIGHEAD = wlr_output_configuration_head_v1_create(CONFIG, m->output);
// TODO: clients off of disabled // TODO: clients off of disabled
wlr_box BOX; wlr_box BOX;
wlr_output_layout_get_box(g_pCompositor->m_sWLROutputLayout, m.output, &BOX); wlr_output_layout_get_box(g_pCompositor->m_sWLROutputLayout, m->output, &BOX);
//m.vecSize.x = BOX.width; //m->vecSize.x = BOX.width;
// m.vecSize.y = BOX.height; // m->vecSize.y = BOX.height;
m.vecPosition.x = BOX.x; m->vecPosition.x = BOX.x;
m.vecPosition.y = BOX.y; m->vecPosition.y = BOX.y;
CONFIGHEAD->state.enabled = m.output->enabled; CONFIGHEAD->state.enabled = m->output->enabled;
CONFIGHEAD->state.mode = m.output->current_mode; CONFIGHEAD->state.mode = m->output->current_mode;
CONFIGHEAD->state.x = m.vecPosition.x; CONFIGHEAD->state.x = m->vecPosition.x;
CONFIGHEAD->state.y = m.vecPosition.y; CONFIGHEAD->state.y = m->vecPosition.y;
wlr_output_set_custom_mode(m.output, m.vecPixelSize.x, m.vecPixelSize.y, (int)(round(m.refreshRate * 1000))); wlr_output_set_custom_mode(m->output, m->vecPixelSize.x, m->vecPixelSize.y, (int)(round(m->refreshRate * 1000)));
} }
wlr_output_manager_v1_set_configuration(g_pCompositor->m_sWLROutputMgr, CONFIG); wlr_output_manager_v1_set_configuration(g_pCompositor->m_sWLROutputMgr, CONFIG);
@ -90,8 +90,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
newMonitor.vecSize = monitorRule.resolution; newMonitor.vecSize = monitorRule.resolution;
newMonitor.refreshRate = monitorRule.refreshRate; newMonitor.refreshRate = monitorRule.refreshRate;
g_pCompositor->m_lMonitors.push_back(newMonitor); const auto PNEWMONITOR = g_pCompositor->m_vMonitors.emplace_back(std::make_unique<SMonitor>(newMonitor)).get();
const auto PNEWMONITOR = &g_pCompositor->m_lMonitors.back();
PNEWMONITOR->hyprListener_monitorFrame.initCallback(&OUTPUT->events.frame, &Events::listener_monitorFrame, PNEWMONITOR); PNEWMONITOR->hyprListener_monitorFrame.initCallback(&OUTPUT->events.frame, &Events::listener_monitorFrame, PNEWMONITOR);
PNEWMONITOR->hyprListener_monitorDestroy.initCallback(&OUTPUT->events.destroy, &Events::listener_monitorDestroy, PNEWMONITOR); PNEWMONITOR->hyprListener_monitorDestroy.initCallback(&OUTPUT->events.destroy, &Events::listener_monitorDestroy, PNEWMONITOR);
@ -115,10 +114,10 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
// Workspace // Workspace
std::string newDefaultWorkspaceName = ""; std::string newDefaultWorkspaceName = "";
auto WORKSPACEID = monitorRule.defaultWorkspace == "" ? g_pCompositor->m_lWorkspaces.size() + 1 : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName); auto WORKSPACEID = monitorRule.defaultWorkspace == "" ? g_pCompositor->m_vWorkspaces.size() + 1 : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
if (WORKSPACEID == INT_MAX || WORKSPACEID == (long unsigned int)SPECIAL_WORKSPACE_ID) { if (WORKSPACEID == INT_MAX || WORKSPACEID == (long unsigned int)SPECIAL_WORKSPACE_ID) {
WORKSPACEID = g_pCompositor->m_lWorkspaces.size() + 1; WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
newDefaultWorkspaceName = std::to_string(WORKSPACEID); newDefaultWorkspaceName = std::to_string(WORKSPACEID);
Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace); Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace);
@ -135,7 +134,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PNEWMONITOR->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PNEWMONITOR->ID);
PNEWWORKSPACE->startAnim(true,true,true); PNEWWORKSPACE->startAnim(true,true,true);
} else { } else {
PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID, newDefaultWorkspaceName); PNEWWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(newMonitor.ID, newDefaultWorkspaceName)).get();
// We are required to set the name here immediately // We are required to set the name here immediately
wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str()); wlr_ext_workspace_handle_v1_set_name(PNEWWORKSPACE->m_pWlrHandle, newDefaultWorkspaceName.c_str());
@ -339,9 +338,9 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
SMonitor* pMonitor = nullptr; SMonitor* pMonitor = nullptr;
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m.szName == OUTPUT->name) { if (m->szName == OUTPUT->name) {
pMonitor = &m; pMonitor = m.get();
break; break;
} }
} }
@ -350,7 +349,7 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
return; return;
// Cleanup everything. Move windows back, snap cursor, shit. // Cleanup everything. Move windows back, snap cursor, shit.
const auto BACKUPMON = &g_pCompositor->m_lMonitors.front(); const auto BACKUPMON = g_pCompositor->m_vMonitors.front().get();
if (!BACKUPMON) { if (!BACKUPMON) {
Debug::log(CRIT, "No monitors! Unplugged last! Exiting."); Debug::log(CRIT, "No monitors! Unplugged last! Exiting.");
@ -366,9 +365,9 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
// move workspaces // move workspaces
std::deque<CWorkspace*> wspToMove; std::deque<CWorkspace*> wspToMove;
for (auto& w : g_pCompositor->m_lWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
if (w.m_iMonitorID == pMonitor->ID) { if (w->m_iMonitorID == pMonitor->ID) {
wspToMove.push_back(&w); wspToMove.push_back(w.get());
} }
} }
@ -379,27 +378,23 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
pMonitor->activeWorkspace = -1; pMonitor->activeWorkspace = -1;
for (auto it = g_pCompositor->m_lWorkspaces.begin(); it != g_pCompositor->m_lWorkspaces.end(); ++it) { g_pCompositor->m_vWorkspaces.erase(std::remove_if(g_pCompositor->m_vWorkspaces.begin(), g_pCompositor->m_vWorkspaces.end(), [&](std::unique_ptr<CWorkspace>& el) { return el->m_iMonitorID == pMonitor->ID; }));
if (it->m_iMonitorID == pMonitor->ID) {
it = g_pCompositor->m_lWorkspaces.erase(it);
}
}
Debug::log(LOG, "Removed monitor %s!", pMonitor->szName.c_str()); Debug::log(LOG, "Removed monitor %s!", pMonitor->szName.c_str());
g_pEventManager->postEvent(SHyprIPCEvent("monitorremoved", pMonitor->szName)); g_pEventManager->postEvent(SHyprIPCEvent("monitorremoved", pMonitor->szName));
g_pCompositor->m_lMonitors.remove(*pMonitor); g_pCompositor->m_vMonitors.erase(std::remove_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](std::unique_ptr<SMonitor>& el) { return el.get() == pMonitor; }));
// update the pMostHzMonitor // update the pMostHzMonitor
if (pMostHzMonitor == pMonitor) { if (pMostHzMonitor == pMonitor) {
int mostHz = 0; int mostHz = 0;
SMonitor* pMonitorMostHz = nullptr; SMonitor* pMonitorMostHz = nullptr;
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m.refreshRate > mostHz) { if (m->refreshRate > mostHz) {
pMonitorMostHz = &m; pMonitorMostHz = m.get();
mostHz = m.refreshRate; mostHz = m->refreshRate;
} }
} }

View file

@ -76,8 +76,7 @@ void Events::listener_newPopup(void* owner, void* data) {
const auto WLRPOPUP = (wlr_xdg_popup*)data; const auto WLRPOPUP = (wlr_xdg_popup*)data;
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup()); const auto PNEWPOPUP = g_pCompositor->m_vXDGPopups.emplace_back(std::make_unique<SXDGPopup>()).get();
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID);
@ -97,8 +96,7 @@ void Events::listener_newPopupXDG(void* owner, void* data) {
const auto WLRPOPUP = (wlr_xdg_popup*)data; const auto WLRPOPUP = (wlr_xdg_popup*)data;
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup()); const auto PNEWPOPUP = g_pCompositor->m_vXDGPopups.emplace_back(std::make_unique<SXDGPopup>()).get();
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
@ -122,8 +120,7 @@ void Events::listener_newPopupFromPopupXDG(void* owner, void* data) {
const auto WLRPOPUP = (wlr_xdg_popup*)data; const auto WLRPOPUP = (wlr_xdg_popup*)data;
g_pCompositor->m_lXDGPopups.push_back(SXDGPopup()); const auto PNEWPOPUP = g_pCompositor->m_vXDGPopups.emplace_back(std::make_unique<SXDGPopup>()).get();
const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back();
PNEWPOPUP->popup = WLRPOPUP; PNEWPOPUP->popup = WLRPOPUP;
PNEWPOPUP->parentPopup = PPOPUP; PNEWPOPUP->parentPopup = PPOPUP;
@ -170,5 +167,5 @@ void Events::listener_destroyPopupXDG(void* owner, void* data) {
PPOPUP->pSurfaceTree = nullptr; PPOPUP->pSurfaceTree = nullptr;
} }
g_pCompositor->m_lXDGPopups.remove(*PPOPUP); g_pCompositor->m_vXDGPopups.erase(std::remove_if(g_pCompositor->m_vXDGPopups.begin(), g_pCompositor->m_vXDGPopups.end(), [&](std::unique_ptr<SXDGPopup>& el) { return el.get() == PPOPUP; }));
} }

View file

@ -43,6 +43,9 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW); PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
PWINDOW->m_fAlpha = 255.f; PWINDOW->m_fAlpha = 255.f;
if (PWINDOW->m_iX11Type == 2)
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
// Set all windows tiled regardless of anything // Set all windows tiled regardless of anything
g_pXWaylandManager->setWindowStyleTiled(PWINDOW, WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM); g_pXWaylandManager->setWindowStyleTiled(PWINDOW, WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM);
@ -57,7 +60,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(PWINDOW); const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(PWINDOW);
if (!PWINDOWSURFACE) { if (!PWINDOWSURFACE) {
g_pCompositor->m_lWindows.remove(*PWINDOW); g_pCompositor->removeWindowFromVectorSafe(PWINDOW);
return; return;
} }
@ -97,7 +100,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
PWINDOW->m_iMonitorID = PMONITOR->ID; PWINDOW->m_iMonitorID = PMONITOR->ID;
} else { } else {
const long int MONITOR = std::stoi(MONITORSTR); const long int MONITOR = std::stoi(MONITORSTR);
if (MONITOR >= (long int)g_pCompositor->m_lMonitors.size() || MONITOR < (long int)0) if (MONITOR >= (long int)g_pCompositor->m_vMonitors.size() || MONITOR < (long int)0)
PWINDOW->m_iMonitorID = 0; PWINDOW->m_iMonitorID = 0;
else else
PWINDOW->m_iMonitorID = MONITOR; PWINDOW->m_iMonitorID = MONITOR;
@ -330,7 +333,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
PWINDOW->m_bFadingOut = true; PWINDOW->m_bFadingOut = true;
g_pCompositor->m_lWindowsFadingOut.push_back(PWINDOW); g_pCompositor->m_vWindowsFadingOut.emplace_back(PWINDOW);
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)); g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID));
@ -474,13 +477,14 @@ void Events::listener_surfaceXWayland(wl_listener* listener, void* data) {
if (XWSURFACE->parent) if (XWSURFACE->parent)
Debug::log(LOG, "Window parent data: %s at %x", XWSURFACE->parent->_class, XWSURFACE->parent); Debug::log(LOG, "Window parent data: %s at %x", XWSURFACE->parent->_class, XWSURFACE->parent);
g_pCompositor->m_lWindows.emplace_back(); const auto PNEWWINDOW = XWSURFACE->override_redirect ? g_pCompositor->m_dUnmanagedX11Windows.emplace_back(std::make_unique<CWindow>()).get() : g_pCompositor->m_vWindows.emplace_back(std::make_unique<CWindow>()).get();
const auto PNEWWINDOW = &g_pCompositor->m_lWindows.back();
PNEWWINDOW->m_uSurface.xwayland = XWSURFACE; PNEWWINDOW->m_uSurface.xwayland = XWSURFACE;
PNEWWINDOW->m_iX11Type = XWSURFACE->override_redirect ? 2 : 1; PNEWWINDOW->m_iX11Type = XWSURFACE->override_redirect ? 2 : 1;
PNEWWINDOW->m_bIsX11 = true; PNEWWINDOW->m_bIsX11 = true;
PNEWWINDOW->m_pX11Parent = g_pCompositor->getX11Parent(PNEWWINDOW);
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XWSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XWayland Window"); PNEWWINDOW->hyprListener_mapWindow.initCallback(&XWSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XWayland Window");
PNEWWINDOW->hyprListener_unmapWindow.initCallback(&XWSURFACE->events.unmap, &Events::listener_unmapWindow, PNEWWINDOW, "XWayland Window"); PNEWWINDOW->hyprListener_unmapWindow.initCallback(&XWSURFACE->events.unmap, &Events::listener_unmapWindow, PNEWWINDOW, "XWayland Window");
PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XWSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XWayland Window"); PNEWWINDOW->hyprListener_destroyWindow.initCallback(&XWSURFACE->events.destroy, &Events::listener_destroyWindow, PNEWWINDOW, "XWayland Window");
@ -495,8 +499,7 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
if (XDGSURFACE->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) if (XDGSURFACE->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL)
return; // TODO: handle? return; // TODO: handle?
g_pCompositor->m_lWindows.emplace_back(); const auto PNEWWINDOW = g_pCompositor->m_vWindows.emplace_back(std::make_unique<CWindow>()).get();
const auto PNEWWINDOW = &g_pCompositor->m_lWindows.back();
PNEWWINDOW->m_uSurface.xdg = XDGSURFACE; PNEWWINDOW->m_uSurface.xdg = XDGSURFACE;
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XDGSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XDG Window"); PNEWWINDOW->hyprListener_mapWindow.initCallback(&XDGSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XDG Window");

View file

@ -219,12 +219,12 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
int lowestID = 99999; int lowestID = 99999;
int highestID = -99999; int highestID = -99999;
for (auto& w : g_pCompositor->m_lWorkspaces) { for (auto& w : g_pCompositor->m_vWorkspaces) {
if (w.m_iID < lowestID) if (w->m_iID < lowestID)
lowestID = w.m_iID; lowestID = w->m_iID;
if (w.m_iID > highestID) if (w->m_iID > highestID)
highestID = w.m_iID; highestID = w->m_iID;
} }
if (remains < 0) if (remains < 0)

View file

@ -12,7 +12,7 @@ void CHyprError::createQueued() {
m_tTexture.destroyTexture(); m_tTexture.destroyTexture();
} }
const auto PMONITOR = &g_pCompositor->m_lMonitors.front(); const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecSize.x, PMONITOR->vecSize.y); const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecSize.x, PMONITOR->vecSize.y);
@ -95,11 +95,11 @@ void CHyprError::draw() {
m_tTexture.destroyTexture(); m_tTexture.destroyTexture();
m_bIsCreated = false; m_bIsCreated = false;
m_szQueued = ""; m_szQueued = "";
g_pHyprRenderer->damageMonitor(&g_pCompositor->m_lMonitors.front()); g_pHyprRenderer->damageMonitor(g_pCompositor->m_vMonitors.front().get());
return; return;
} }
const auto PMONITOR = &g_pCompositor->m_lMonitors.front(); const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
if (g_pHyprOpenGL->m_RenderData.pMonitor != PMONITOR) if (g_pHyprOpenGL->m_RenderData.pMonitor != PMONITOR)
return; // wrong mon return; // wrong mon

View file

@ -117,3 +117,5 @@ extern "C" {
#include "helpers/Vector2D.hpp" #include "helpers/Vector2D.hpp"
#include "ext-workspace-unstable-v1-protocol.h" #include "ext-workspace-unstable-v1-protocol.h"
#include <algorithm>

View file

@ -145,14 +145,14 @@ void CAnimationManager::tick() {
g_pHyprRenderer->damageWindow(PWINDOW); g_pHyprRenderer->damageWindow(PWINDOW);
PWINDOW->updateWindowDecos(); PWINDOW->updateWindowDecos();
} else if (PWORKSPACE) { } else if (PWORKSPACE) {
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!w.m_bIsMapped || w.m_bHidden) if (!w->m_bIsMapped || w->m_bHidden)
continue; continue;
if (w.m_iWorkspaceID != PWORKSPACE->m_iID) if (w->m_iWorkspaceID != PWORKSPACE->m_iID)
continue; continue;
w.updateWindowDecos(); w->updateWindowDecos();
} }
} }
break; break;

View file

@ -118,10 +118,10 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
const int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1; const int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
wlr_session_change_vt(PSESSION, TTY); wlr_session_change_vt(PSESSION, TTY);
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
g_pHyprOpenGL->destroyMonitorResources(&m); // mark resources as unusable anymore g_pHyprOpenGL->destroyMonitorResources(m.get()); // mark resources as unusable anymore
m.noFrameSchedule = true; m->noFrameSchedule = true;
m.framesToSkip = 2; m->framesToSkip = 2;
} }
Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY); Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY);
@ -339,8 +339,7 @@ void CKeybindManager::changeworkspace(std::string args) {
if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE) if (const auto POLDWORKSPACE = g_pCompositor->getWorkspaceByID(OLDWORKSPACE); POLDWORKSPACE)
POLDWORKSPACE->startAnim(false, ANIMTOLEFT); POLDWORKSPACE->startAnim(false, ANIMTOLEFT);
g_pCompositor->m_lWorkspaces.emplace_back(PMONITOR->ID, workspaceName, workspaceToChangeTo == SPECIAL_WORKSPACE_ID); const auto PWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique<CWorkspace>(PMONITOR->ID, workspaceName, workspaceToChangeTo == SPECIAL_WORKSPACE_ID)).get();
const auto PWORKSPACE = &g_pCompositor->m_lWorkspaces.back();
// start anim on new workspace // start anim on new workspace
PWORKSPACE->startAnim(true, ANIMTOLEFT); PWORKSPACE->startAnim(true, ANIMTOLEFT);
@ -456,8 +455,8 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
toggleSpecialWorkspace(""); toggleSpecialWorkspace("");
g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false, true); g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false, true);
for (auto& m : g_pCompositor->m_lMonitors) for (auto& m : g_pCompositor->m_vMonitors)
m.specialWorkspaceOpen = false; m->specialWorkspaceOpen = false;
} }
g_pInputManager->refocus(); g_pInputManager->refocus();
@ -662,7 +661,7 @@ void CKeybindManager::focusMonitor(std::string arg) {
Debug::log(ERR, "Error in focusMonitor: invalid num"); Debug::log(ERR, "Error in focusMonitor: invalid num");
} }
if (monID > -1 && monID < (int)g_pCompositor->m_lMonitors.size()) { if (monID > -1 && monID < (int)g_pCompositor->m_vMonitors.size()) {
changeworkspace(std::to_string(g_pCompositor->getMonitorFromID(monID)->activeWorkspace)); changeworkspace(std::to_string(g_pCompositor->getMonitorFromID(monID)->activeWorkspace));
} else { } else {
Debug::log(ERR, "Error in focusMonitor: invalid arg 1"); Debug::log(ERR, "Error in focusMonitor: invalid arg 1");
@ -681,9 +680,9 @@ void CKeybindManager::focusMonitor(std::string arg) {
return; return;
} }
} else { } else {
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m.szName == arg) { if (m->szName == arg) {
changeworkspace(std::to_string(m.activeWorkspace)); changeworkspace(std::to_string(m->activeWorkspace));
return; return;
} }
} }
@ -743,11 +742,11 @@ void CKeybindManager::workspaceOpt(std::string args) {
PWORKSPACE->m_bDefaultPseudo = !PWORKSPACE->m_bDefaultPseudo; PWORKSPACE->m_bDefaultPseudo = !PWORKSPACE->m_bDefaultPseudo;
// apply // apply
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!w.m_bIsMapped || w.m_iWorkspaceID != PWORKSPACE->m_iID) if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID)
continue; continue;
w.m_bIsPseudotiled = PWORKSPACE->m_bDefaultPseudo; w->m_bIsPseudotiled = PWORKSPACE->m_bDefaultPseudo;
} }
} else if (args == "allfloat") { } else if (args == "allfloat") {
PWORKSPACE->m_bDefaultFloating = !PWORKSPACE->m_bDefaultFloating; PWORKSPACE->m_bDefaultFloating = !PWORKSPACE->m_bDefaultFloating;
@ -755,8 +754,8 @@ void CKeybindManager::workspaceOpt(std::string args) {
// we make a copy because changeWindowFloatingMode might invalidate the iterator // we make a copy because changeWindowFloatingMode might invalidate the iterator
std::deque<CWindow*> ptrs; std::deque<CWindow*> ptrs;
for (auto& w : g_pCompositor->m_lWindows) for (auto& w : g_pCompositor->m_vWindows)
ptrs.push_back(&w); ptrs.push_back(w.get());
for (auto& w : ptrs) { for (auto& w : ptrs) {
if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID) if (!w->m_bIsMapped || w->m_iWorkspaceID != PWORKSPACE->m_iID)
@ -860,8 +859,8 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
bool open = false; bool open = false;
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m.specialWorkspaceOpen) { if (m->specialWorkspaceOpen) {
open = true; open = true;
break; break;
} }
@ -873,10 +872,10 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
Debug::log(LOG, "Toggling special workspace to open"); Debug::log(LOG, "Toggling special workspace to open");
if (open) { if (open) {
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (m.specialWorkspaceOpen != !open) { if (m->specialWorkspaceOpen != !open) {
m.specialWorkspaceOpen = !open; m->specialWorkspaceOpen = !open;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false); g_pCompositor->getWorkspaceByID(SPECIAL_WORKSPACE_ID)->startAnim(false, false);
} }
@ -895,9 +894,9 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
} }
void CKeybindManager::forceRendererReload(std::string args) { void CKeybindManager::forceRendererReload(std::string args) {
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
auto rule = g_pConfigManager->getMonitorRuleFor(m.szName); auto rule = g_pConfigManager->getMonitorRuleFor(m->szName);
g_pHyprRenderer->applyMonitorRule(&m, &rule, true); g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true);
} }
} }
@ -1013,22 +1012,22 @@ void CKeybindManager::circleNext(std::string) {
void CKeybindManager::focusWindowByClass(std::string clazz) { void CKeybindManager::focusWindowByClass(std::string clazz) {
std::regex classCheck(clazz); std::regex classCheck(clazz);
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!w.m_bIsMapped || w.m_bHidden) if (!w->m_bIsMapped || w->m_bHidden)
continue; continue;
const auto windowClass = g_pXWaylandManager->getAppIDClass(&w); const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get());
if (!std::regex_search(windowClass, classCheck)) if (!std::regex_search(windowClass, classCheck))
continue; continue;
Debug::log(LOG, "Focusing to window name: %s", w.m_szTitle.c_str()); Debug::log(LOG, "Focusing to window name: %s", w->m_szTitle.c_str());
changeworkspace(std::to_string(w.m_iWorkspaceID)); changeworkspace(std::to_string(w->m_iWorkspaceID));
g_pCompositor->focusWindow(&w); g_pCompositor->focusWindow(w.get());
const auto MIDPOINT = w.m_vRealPosition.goalv() + w.m_vRealSize.goalv() / 2.f; const auto MIDPOINT = w->m_vRealPosition.goalv() + w->m_vRealSize.goalv() / 2.f;
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y); wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, MIDPOINT.x, MIDPOINT.y);

View file

@ -123,10 +123,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
surfacePos = pFoundWindow->m_vRealPosition.vec(); surfacePos = pFoundWindow->m_vRealPosition.vec();
// only check floating because tiled cant be over fullscreen // only check floating because tiled cant be over fullscreen
for (auto w = g_pCompositor->m_lWindows.rbegin(); w != g_pCompositor->m_lWindows.rend(); w++) { for (auto w = g_pCompositor->m_vWindows.rbegin(); w != g_pCompositor->m_vWindows.rend(); w++) {
wlr_box box = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y}; wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
if (((w->m_bIsFloating && w->m_bIsMapped && w->m_bCreatedOverFullscreen) || (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->m_bHidden) { if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && (*w)->m_bCreatedOverFullscreen) || ((*w)->m_iWorkspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bHidden) {
pFoundWindow = &(*w); pFoundWindow = (*w).get();
if (!pFoundWindow->m_bIsX11) { if (!pFoundWindow->m_bIsX11) {
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);

View file

@ -74,11 +74,11 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID)) if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID))
return true; return true;
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
if (PWORKSPACE && PWORKSPACE->m_iMonitorID == m.ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())) if (PWORKSPACE && PWORKSPACE->m_iMonitorID == m->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated()))
return true; return true;
if (m.specialWorkspaceOpen && pWindow->m_iWorkspaceID == SPECIAL_WORKSPACE_ID) if (m->specialWorkspaceOpen && pWindow->m_iWorkspaceID == SPECIAL_WORKSPACE_ID)
return true; return true;
} }
@ -88,37 +88,37 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) { void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) {
CWindow* pWorkspaceWindow = nullptr; CWindow* pWorkspaceWindow = nullptr;
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w.m_iWorkspaceID != pWorkspace->m_iID || !w.m_bIsFullscreen) if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen)
continue; continue;
// found it! // found it!
renderWindow(&w, pMonitor, time, pWorkspace->m_efFullscreenMode != FULLSCREEN_FULL); renderWindow(w.get(), pMonitor, time, pWorkspace->m_efFullscreenMode != FULLSCREEN_FULL);
pWorkspaceWindow = &w; pWorkspaceWindow = w.get();
} }
// then render windows over fullscreen // then render windows over fullscreen
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (w.m_iWorkspaceID != pWorkspaceWindow->m_iWorkspaceID || !w.m_bCreatedOverFullscreen || !w.m_bIsMapped) if (w->m_iWorkspaceID != pWorkspaceWindow->m_iWorkspaceID || !w->m_bCreatedOverFullscreen || !w->m_bIsMapped)
continue; continue;
renderWindow(&w, pMonitor, time, true); renderWindow(w.get(), pMonitor, time, true);
} }
// and then special windows // and then special windows
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(&w) && !w.m_bFadingOut) if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut)
continue; continue;
if (w.m_iWorkspaceID != SPECIAL_WORKSPACE_ID) if (w->m_iWorkspaceID != SPECIAL_WORKSPACE_ID)
continue; continue;
if (!shouldRenderWindow(&w, pMonitor)) if (!shouldRenderWindow(w.get(), pMonitor))
continue; continue;
// render the bad boy // render the bad boy
renderWindow(&w, pMonitor, time, true); renderWindow(w.get(), pMonitor, time, true);
} }
// and the overlay layers // and the overlay layers
@ -136,7 +136,7 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(SMonitor* pMonitor, CWor
renderDragIcon(pMonitor, time); renderDragIcon(pMonitor, time);
// if correct monitor draw hyprerror // if correct monitor draw hyprerror
if (pMonitor == &g_pCompositor->m_lMonitors.front()) if (pMonitor == g_pCompositor->m_vMonitors.front().get())
g_pHyprError->draw(); g_pHyprError->draw();
} }
@ -244,54 +244,54 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
} }
// Non-floating // Non-floating
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(&w) && !w.m_bFadingOut) if (w->m_bHidden && !w->m_bIsMapped && !w->m_bFadingOut)
continue; continue;
if (w.m_bIsFloating) if (w->m_bIsFloating)
continue; // floating are in the second pass continue; // floating are in the second pass
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID) if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID)
continue; // special are in the third pass continue; // special are in the third pass
if (!shouldRenderWindow(&w, PMONITOR)) if (!shouldRenderWindow(w.get(), PMONITOR))
continue; continue;
// render the bad boy // render the bad boy
renderWindow(&w, PMONITOR, time, true); renderWindow(w.get(), PMONITOR, time, true);
} }
// floating on top // floating on top
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(&w) && !w.m_bFadingOut) if (w->m_bHidden && !w->m_bIsMapped && !w->m_bFadingOut)
continue; continue;
if (!w.m_bIsFloating) if (!w->m_bIsFloating)
continue; continue;
if (w.m_iWorkspaceID == SPECIAL_WORKSPACE_ID) if (w->m_iWorkspaceID == SPECIAL_WORKSPACE_ID)
continue; continue;
if (!shouldRenderWindow(&w, PMONITOR)) if (!shouldRenderWindow(w.get(), PMONITOR))
continue; continue;
// render the bad boy // render the bad boy
renderWindow(&w, PMONITOR, time, true); renderWindow(w.get(), PMONITOR, time, true);
} }
// and then special // and then special
for (auto& w : g_pCompositor->m_lWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(&w) && !w.m_bFadingOut) if (w->m_bHidden && !w->m_bIsMapped && !w->m_bFadingOut)
continue; continue;
if (w.m_iWorkspaceID != SPECIAL_WORKSPACE_ID) if (w->m_iWorkspaceID != SPECIAL_WORKSPACE_ID)
continue; continue;
if (!shouldRenderWindow(&w, PMONITOR)) if (!shouldRenderWindow(w.get(), PMONITOR))
continue; continue;
// render the bad boy // render the bad boy
renderWindow(&w, PMONITOR, time, true); renderWindow(w.get(), PMONITOR, time, true);
} }
// Render surfaces above windows for monitor // Render surfaces above windows for monitor
@ -558,12 +558,12 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
pixman_region32_translate(&damageBox, x, y); pixman_region32_translate(&damageBox, x, y);
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
double lx = 0, ly = 0; double lx = 0, ly = 0;
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, m.output, &lx, &ly); wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, m->output, &lx, &ly);
pixman_region32_translate(&damageBox, lx, ly); pixman_region32_translate(&damageBox, lx, ly);
wlr_region_scale(&damageBox, &damageBox, m.scale); wlr_region_scale(&damageBox, &damageBox, m->scale);
wlr_output_damage_add(m.damage, &damageBox); wlr_output_damage_add(m->damage, &damageBox);
pixman_region32_translate(&damageBox, -lx, -ly); pixman_region32_translate(&damageBox, -lx, -ly);
} }
@ -577,10 +577,10 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
void CHyprRenderer::damageWindow(CWindow* pWindow) { void CHyprRenderer::damageWindow(CWindow* pWindow) {
wlr_box damageBox = pWindow->getFullWindowBoundingBox(); wlr_box damageBox = pWindow->getFullWindowBoundingBox();
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
wlr_box fixedDamageBox = {damageBox.x - m.vecPosition.x, damageBox.y - m.vecPosition.y, damageBox.width, damageBox.height}; wlr_box fixedDamageBox = {damageBox.x - m->vecPosition.x, damageBox.y - m->vecPosition.y, damageBox.width, damageBox.height};
scaleBox(&fixedDamageBox, m.scale); scaleBox(&fixedDamageBox, m->scale);
wlr_output_damage_add_box(m.damage, &fixedDamageBox); wlr_output_damage_add_box(m->damage, &fixedDamageBox);
} }
static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
@ -600,10 +600,10 @@ void CHyprRenderer::damageMonitor(SMonitor* pMonitor) {
} }
void CHyprRenderer::damageBox(wlr_box* pBox) { void CHyprRenderer::damageBox(wlr_box* pBox) {
for (auto& m : g_pCompositor->m_lMonitors) { for (auto& m : g_pCompositor->m_vMonitors) {
wlr_box damageBox = {pBox->x - m.vecPosition.x, pBox->y - m.vecPosition.y, pBox->width, pBox->height}; wlr_box damageBox = {pBox->x - m->vecPosition.x, pBox->y - m->vecPosition.y, pBox->width, pBox->height};
scaleBox(&damageBox, m.scale); scaleBox(&damageBox, m->scale);
wlr_output_damage_add_box(m.damage, &damageBox); wlr_output_damage_add_box(m->damage, &damageBox);
} }
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue; static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
@ -768,8 +768,8 @@ void CHyprRenderer::ensureCursorRenderingMode() {
Debug::log(LOG, "Hiding the cursor (timeout)"); Debug::log(LOG, "Hiding the cursor (timeout)");
for (auto& m : g_pCompositor->m_lMonitors) for (auto& m : g_pCompositor->m_vMonitors)
g_pHyprRenderer->damageMonitor(&m); // TODO: maybe just damage the cursor area? g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area?
} else if (*PCURSORTIMEOUT > PASSEDCURSORSECONDS && !m_bHasARenderedCursor) { } else if (*PCURSORTIMEOUT > PASSEDCURSORSECONDS && !m_bHasARenderedCursor) {
m_bHasARenderedCursor = true; m_bHasARenderedCursor = true;
@ -778,8 +778,8 @@ void CHyprRenderer::ensureCursorRenderingMode() {
Debug::log(LOG, "Showing the cursor (timeout)"); Debug::log(LOG, "Showing the cursor (timeout)");
for (auto& m : g_pCompositor->m_lMonitors) for (auto& m : g_pCompositor->m_vMonitors)
g_pHyprRenderer->damageMonitor(&m); // TODO: maybe just damage the cursor area? g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area?
} }
} else { } else {
m_bHasARenderedCursor = true; m_bHasARenderedCursor = true;