Convert reverse iterators to ranges

This commit is contained in:
vaxerski 2023-03-01 14:06:52 +00:00
parent 3cef005fec
commit 7c5c7ced91
3 changed files with 95 additions and 94 deletions

View file

@ -6,6 +6,7 @@
#ifdef USES_SYSTEMD #ifdef USES_SYSTEMD
#include <systemd/sd-daemon.h> // for sd_notify #include <systemd/sd-daemon.h> // for sd_notify
#endif #endif
#include <ranges>
int handleCritSignal(int signo, void* data) { int handleCritSignal(int signo, void* data) {
Debug::log(LOG, "Hyprland received signal %d", signo); Debug::log(LOG, "Hyprland received signal %d", signo);
@ -537,10 +538,10 @@ CWindow* CCompositor::vectorToWindow(const Vector2D& pos) {
const auto PMONITOR = getMonitorFromVector(pos); const auto PMONITOR = getMonitorFromVector(pos);
if (PMONITOR->specialWorkspaceID) { if (PMONITOR->specialWorkspaceID) {
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
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_iWorkspaceID == PMONITOR->specialWorkspaceID && (*w)->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !(*w)->isHidden()) if (w->m_bIsFloating && w->m_iWorkspaceID == PMONITOR->specialWorkspaceID && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w->isHidden())
return (*w).get(); return w.get();
} }
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
@ -551,18 +552,17 @@ CWindow* CCompositor::vectorToWindow(const Vector2D& pos) {
} }
// pinned // pinned
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
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 && !(*w)->isHidden() && (*w)->m_bPinned) if (wlr_box_contains_point(&box, pos.x, pos.y) && w->m_bIsMapped && w->m_bIsFloating && !w->isHidden() && w->m_bPinned)
return w->get(); return w.get();
} }
// first loop over floating cuz they're above, m_vWindows should be sorted bottom->top, for tiled it doesn't matter. // first loop over floating cuz they're above, m_vWindows should be sorted bottom->top, for tiled it doesn't matter.
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
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)->isHidden() && if (wlr_box_contains_point(&box, pos.x, pos.y) && w->m_bIsMapped && w->m_bIsFloating && isWorkspaceVisible(w->m_iWorkspaceID) && !w->isHidden() && !w->m_bPinned)
!(*w)->m_bPinned) return w.get();
return w->get();
} }
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
@ -603,12 +603,12 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
// special workspace // special workspace
if (PMONITOR->specialWorkspaceID) { if (PMONITOR->specialWorkspaceID) {
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
const auto BB = w->get()->getWindowInputBox(); const auto BB = w->getWindowInputBox();
wlr_box box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA}; wlr_box box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA};
if ((*w)->m_bIsFloating && (*w)->m_iWorkspaceID == PMONITOR->specialWorkspaceID && (*w)->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && if (w->m_bIsFloating && w->m_iWorkspaceID == PMONITOR->specialWorkspaceID && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w->isHidden() &&
!(*w)->isHidden() && !(*w)->m_bX11ShouldntFocus) !w->m_bX11ShouldntFocus)
return (*w).get(); return w.get();
} }
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
@ -620,43 +620,43 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
} }
// pinned windows on top of floating regardless // pinned windows on top of floating regardless
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
const auto BB = w->get()->getWindowInputBox(); const auto BB = w->getWindowInputBox();
wlr_box box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA}; wlr_box box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA};
if ((*w)->m_bIsFloating && (*w)->m_bIsMapped && !(*w)->isHidden() && !(*w)->m_bX11ShouldntFocus && (*w)->m_bPinned) { if (w->m_bIsFloating && w->m_bIsMapped && !w->isHidden() && !w->m_bX11ShouldntFocus && w->m_bPinned) {
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y)) if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y))
return w->get(); return w.get();
if (!(*w)->m_bIsX11) { if (!w->m_bIsX11) {
if ((*w)->hasPopupAt(pos)) if (w->hasPopupAt(pos))
return w->get(); 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_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
const auto BB = w->get()->getWindowInputBox(); const auto BB = w->getWindowInputBox();
wlr_box box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA}; wlr_box box = {BB.x - BORDER_GRAB_AREA, BB.y - BORDER_GRAB_AREA, BB.width + 2 * BORDER_GRAB_AREA, BB.height + 2 * BORDER_GRAB_AREA};
if ((*w)->m_bIsFloating && (*w)->m_bIsMapped && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden() && !(*w)->m_bPinned) { if (w->m_bIsFloating && w->m_bIsMapped && isWorkspaceVisible(w->m_iWorkspaceID) && !w->isHidden() && !w->m_bPinned) {
// OR windows should add focus to parent // OR windows should add focus to parent
if ((*w)->m_bX11ShouldntFocus && (*w)->m_iX11Type != 2) if (w->m_bX11ShouldntFocus && w->m_iX11Type != 2)
continue; continue;
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y)) { if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y)) {
if ((*w)->m_bIsX11 && (*w)->m_iX11Type == 2 && !wlr_xwayland_or_surface_wants_focus((*w)->m_uSurface.xwayland)) { if (w->m_bIsX11 && w->m_iX11Type == 2 && !wlr_xwayland_or_surface_wants_focus(w->m_uSurface.xwayland)) {
// Override Redirect // Override Redirect
return g_pCompositor->m_pLastWindow; // we kinda trick everything here. return g_pCompositor->m_pLastWindow; // we kinda trick everything here.
// TODO: this is wrong, we should focus the parent, but idk how to get it considering it's nullptr in most cases. // TODO: this is wrong, we should focus the parent, but idk how to get it considering it's nullptr in most cases.
} }
return w->get(); return w.get();
} }
if (!(*w)->m_bIsX11) { if (!w->m_bIsX11) {
if ((*w)->hasPopupAt(pos)) if (w->hasPopupAt(pos))
return w->get(); return w.get();
} }
} }
} }
@ -682,11 +682,11 @@ CWindow* CCompositor::windowFromCursor() {
const auto PMONITOR = getMonitorFromCursor(); const auto PMONITOR = getMonitorFromCursor();
if (PMONITOR->specialWorkspaceID) { if (PMONITOR->specialWorkspaceID) {
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
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_iWorkspaceID == PMONITOR->specialWorkspaceID && (*w)->m_bIsMapped && if (w->m_bIsFloating && w->m_iWorkspaceID == PMONITOR->specialWorkspaceID && w->m_bIsMapped && wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) &&
wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && !(*w)->isHidden()) !w->isHidden())
return (*w).get(); return w.get();
} }
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
@ -697,18 +697,17 @@ CWindow* CCompositor::windowFromCursor() {
} }
// pinned // pinned
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
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 && (*w)->m_bPinned) if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w->m_bIsMapped && w->m_bIsFloating && w->m_bPinned)
return w->get(); 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_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
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) && !w->m_bPinned)
!(*w)->m_bPinned) return w.get();
return w->get();
} }
for (auto& w : m_vWindows) { for (auto& w : m_vWindows) {
@ -721,17 +720,17 @@ CWindow* CCompositor::windowFromCursor() {
} }
CWindow* CCompositor::windowFloatingFromCursor() { CWindow* CCompositor::windowFloatingFromCursor() {
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
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 && !(*w)->isHidden() && (*w)->m_bPinned) if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && w->m_bIsMapped && w->m_bIsFloating && !w->isHidden() && w->m_bPinned)
return w->get(); return w.get();
} }
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) { for (auto& w : m_vWindows | std::views::reverse) {
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) && !w->isHidden() &&
!(*w)->isHidden() && !(*w)->m_bPinned) !w->m_bPinned)
return w->get(); return w.get();
} }
return nullptr; return nullptr;
@ -981,21 +980,21 @@ CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) {
wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<std::unique_ptr<SLayerSurface>>* layerSurfaces, Vector2D* sCoords, wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<std::unique_ptr<SLayerSurface>>* layerSurfaces, Vector2D* sCoords,
SLayerSurface** ppLayerSurfaceFound) { SLayerSurface** ppLayerSurfaceFound) {
for (auto it = layerSurfaces->rbegin(); it != layerSurfaces->rend(); it++) { for (auto& ls : *layerSurfaces | std::views::reverse) {
if ((*it)->fadingOut || !(*it)->layerSurface || ((*it)->layerSurface && !(*it)->layerSurface->mapped) || (*it)->alpha.fl() == 0.f) if (ls->fadingOut || !ls->layerSurface || (ls->layerSurface && !ls->layerSurface->mapped) || ls->alpha.fl() == 0.f)
continue; continue;
auto SURFACEAT = wlr_layer_surface_v1_surface_at((*it)->layerSurface, pos.x - (*it)->geometry.x, pos.y - (*it)->geometry.y, &sCoords->x, &sCoords->y); auto SURFACEAT = wlr_layer_surface_v1_surface_at(ls->layerSurface, pos.x - ls->geometry.x, pos.y - ls->geometry.y, &sCoords->x, &sCoords->y);
if (!SURFACEAT && VECINRECT(pos, (*it)->geometry.x, (*it)->geometry.y, (*it)->geometry.x + (*it)->geometry.width, (*it)->geometry.y + (*it)->geometry.height)) { if (!SURFACEAT && VECINRECT(pos, ls->geometry.x, ls->geometry.y, ls->geometry.x + ls->geometry.width, ls->geometry.y + ls->geometry.height)) {
SURFACEAT = (*it)->layerSurface->surface; SURFACEAT = ls->layerSurface->surface;
} }
if ((*it)->layerSurface->current.keyboard_interactive && (*it)->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) { if (ls->layerSurface->current.keyboard_interactive && ls->layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
if (!SURFACEAT) if (!SURFACEAT)
SURFACEAT = (*it)->layerSurface->surface; SURFACEAT = ls->layerSurface->surface;
*ppLayerSurfaceFound = it->get(); *ppLayerSurfaceFound = ls.get();
return SURFACEAT; return SURFACEAT;
} }
@ -1003,7 +1002,7 @@ wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<
if (!pixman_region32_not_empty(&SURFACEAT->input_region)) if (!pixman_region32_not_empty(&SURFACEAT->input_region))
continue; continue;
*ppLayerSurfaceFound = it->get(); *ppLayerSurfaceFound = ls.get();
return SURFACEAT; return SURFACEAT;
} }
} }
@ -1429,22 +1428,22 @@ CWindow* CCompositor::getNextWindowOnWorkspace(CWindow* pWindow, bool focusableO
CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) { CWindow* CCompositor::getPrevWindowOnWorkspace(CWindow* pWindow, bool focusableOnly) {
bool gotToWindow = false; bool gotToWindow = false;
for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); it++) { for (auto& w : m_vWindows | std::views::reverse) {
if (it->get() != pWindow && !gotToWindow) if (w.get() != pWindow && !gotToWindow)
continue; continue;
if (it->get() == pWindow) { if (w.get() == pWindow) {
gotToWindow = true; gotToWindow = true;
continue; continue;
} }
if ((*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->isHidden() && (!focusableOnly || !(*it)->m_bNoFocus)) if (w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
return it->get(); return w.get();
} }
for (auto it = m_vWindows.rbegin(); it != m_vWindows.rend(); it++) { for (auto& w : m_vWindows | std::views::reverse) {
if (it->get() != pWindow && (*it)->m_iWorkspaceID == pWindow->m_iWorkspaceID && (*it)->m_bIsMapped && !(*it)->isHidden() && (!focusableOnly || !(*it)->m_bNoFocus)) if (w.get() != pWindow && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && w->m_bIsMapped && !w->isHidden() && (!focusableOnly || !w->m_bNoFocus))
return it->get(); return w.get();
} }
return nullptr; return nullptr;

View file

@ -1,5 +1,6 @@
#include "MasterLayout.hpp" #include "MasterLayout.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include <ranges>
SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(CWindow* pWindow) { SMasterNodeData* CHyprMasterLayout::getNodeFromWindow(CWindow* pWindow) {
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {
@ -175,9 +176,9 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
m_lMasterNodesData.remove(*PNODE); m_lMasterNodesData.remove(*PNODE);
if (getMastersOnWorkspace(WORKSPACEID) == getNodesOnWorkspace(WORKSPACEID) && MASTERSLEFT > 1) { if (getMastersOnWorkspace(WORKSPACEID) == getNodesOnWorkspace(WORKSPACEID) && MASTERSLEFT > 1) {
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { for (auto& nd : m_lMasterNodesData | std::views::reverse) {
if (it->workspaceID == WORKSPACEID) { if (nd.workspaceID == WORKSPACEID) {
it->isMaster = false; nd.isMaster = false;
break; break;
} }
} }
@ -781,23 +782,23 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
} else { } else {
if (PNODE->isMaster) { if (PNODE->isMaster) {
// focus the last non master // focus the last non master
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { for (auto& nd : m_lMasterNodesData | std::views::reverse) {
if (it->pWindow != pWindow && it->workspaceID == pWindow->m_iWorkspaceID) { if (nd.pWindow != pWindow && nd.workspaceID == pWindow->m_iWorkspaceID) {
return it->pWindow; return nd.pWindow;
} }
} }
} else { } else {
// focus previous // focus previous
bool reached = false; bool reached = false;
bool found = false; bool found = false;
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { for (auto& nd : m_lMasterNodesData | std::views::reverse) {
if (it->pWindow == pWindow) { if (nd.pWindow == pWindow) {
reached = true; reached = true;
continue; continue;
} }
if (it->workspaceID == pWindow->m_iWorkspaceID && reached) { if (nd.workspaceID == pWindow->m_iWorkspaceID && reached) {
return it->pWindow; return nd.pWindow;
} }
} }
if (!found) { if (!found) {
@ -1037,9 +1038,9 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
if (!PNODE || !PNODE->isMaster) { if (!PNODE || !PNODE->isMaster) {
// first non-master node // first non-master node
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) { for (auto& nd : m_lMasterNodesData | std::views::reverse) {
if (it->workspaceID == header.pWindow->m_iWorkspaceID && it->isMaster) { if (nd.workspaceID == header.pWindow->m_iWorkspaceID && nd.isMaster) {
it->isMaster = false; nd.isMaster = false;
break; break;
} }
} }

View file

@ -1,6 +1,7 @@
#include "InputManager.hpp" #include "InputManager.hpp"
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
#include "wlr/types/wlr_switch.h" #include "wlr/types/wlr_switch.h"
#include <ranges>
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) { void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
static auto* const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue; static auto* const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
@ -182,13 +183,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
} }
// only check floating because tiled cant be over fullscreen // only check floating because tiled cant be over fullscreen
for (auto w = g_pCompositor->m_vWindows.rbegin(); w != g_pCompositor->m_vWindows.rend(); w++) { for (auto& w : g_pCompositor->m_vWindows | std::views::reverse) {
wlr_box box = {(*w)->m_vRealPosition.vec().x - BORDER_GRAB_AREA, (*w)->m_vRealPosition.vec().y - BORDER_GRAB_AREA, (*w)->m_vRealSize.vec().x + 2 * BORDER_GRAB_AREA, wlr_box box = {w->m_vRealPosition.vec().x - BORDER_GRAB_AREA, w->m_vRealPosition.vec().y - BORDER_GRAB_AREA, w->m_vRealSize.vec().x + 2 * BORDER_GRAB_AREA,
(*w)->m_vRealSize.vec().y + 2 * BORDER_GRAB_AREA}; w->m_vRealSize.vec().y + 2 * BORDER_GRAB_AREA};
if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && ((*w)->m_bCreatedOverFullscreen || (*w)->m_bPinned)) || if (((w->m_bIsFloating && w->m_bIsMapped && (w->m_bCreatedOverFullscreen || w->m_bPinned)) ||
(g_pCompositor->isWorkspaceSpecial((*w)->m_iWorkspaceID) && PMONITOR->specialWorkspaceID)) && (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID) && PMONITOR->specialWorkspaceID)) &&
wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden()) { wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID) && !w->isHidden()) {
pFoundWindow = (*w).get(); pFoundWindow = w.get();
break; break;
} }
} }