aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/managers
diff options
context:
space:
mode:
authorVaxry <[email protected]>2023-11-04 17:03:05 +0000
committerGitHub <[email protected]>2023-11-04 17:03:05 +0000
commit55b4f84fea33adee3ec4b0a69c2bca6e7a1f5754 (patch)
treebe7db4f841b4ac049527daae01e683701bf92b92 /src/managers
parent73e78f05ad5cafa20ac5bf177c94ac9ecca37097 (diff)
downloadHyprland-55b4f84fea33adee3ec4b0a69c2bca6e7a1f5754.tar.gz
Hyprland-55b4f84fea33adee3ec4b0a69c2bca6e7a1f5754.zip
Internal: Hyprland box implementation (#3755)
* box impl * remove unused operators * missed applyfromwlr
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/AnimationManager.cpp9
-rw-r--r--src/managers/XWaylandManager.cpp8
-rw-r--r--src/managers/XWaylandManager.hpp2
-rw-r--r--src/managers/input/InputManager.cpp26
-rw-r--r--src/managers/input/InputMethodRelay.cpp6
5 files changed, 26 insertions, 25 deletions
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index a7d05030..1dc8e2c6 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -81,7 +81,7 @@ void CAnimationManager::tick() {
CMonitor* PMONITOR = nullptr;
bool animationsDisabled = animGlobalDisabled;
- wlr_box WLRBOXPREV = {0, 0, 0, 0};
+ CBox WLRBOXPREV = {0, 0, 0, 0};
if (PWINDOW) {
WLRBOXPREV = PWINDOW->getFullWindowBoundingBox();
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
@@ -236,7 +236,7 @@ void CAnimationManager::tick() {
BORDERSIZE + ROUNDINGSIZE); // bottom
// damage for new box
- const wlr_box WLRBOXNEW = {PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y, PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealSize.vec().y};
+ const CBox WLRBOXNEW = {PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y, PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealSize.vec().y};
g_pHyprRenderer->damageBox(WLRBOXNEW.x - BORDERSIZE, WLRBOXNEW.y - BORDERSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // top
g_pHyprRenderer->damageBox(WLRBOXNEW.x - BORDERSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXNEW.height + 2 * BORDERSIZE); // left
g_pHyprRenderer->damageBox(WLRBOXNEW.x + WLRBOXNEW.width - ROUNDINGSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE,
@@ -255,9 +255,8 @@ void CAnimationManager::tick() {
if (PDECO) {
const auto EXTENTS = PDECO->getWindowDecorationExtents();
- wlr_box dmg = {PWINDOW->m_vRealPosition.vec().x - EXTENTS.topLeft.x, PWINDOW->m_vRealPosition.vec().y - EXTENTS.topLeft.y,
- PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x,
- PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y};
+ CBox dmg = {PWINDOW->m_vRealPosition.vec().x - EXTENTS.topLeft.x, PWINDOW->m_vRealPosition.vec().y - EXTENTS.topLeft.y,
+ PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x, PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y};
if (!*PSHADOWIGNOREWINDOW) {
// easy, damage the entire box
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp
index a40647fa..04fbaf21 100644
--- a/src/managers/XWaylandManager.cpp
+++ b/src/managers/XWaylandManager.cpp
@@ -74,7 +74,7 @@ void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) {
g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID)->m_pLastFocusedWindow = pWindow;
}
-void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, wlr_box* pbox) {
+void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, CBox* pbox) {
if (pWindow->m_bIsX11) {
const auto SIZEHINTS = pWindow->m_uSurface.xwayland->size_hints;
@@ -89,8 +89,10 @@ void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, wlr_box* pbox)
pbox->width = pWindow->m_uSurface.xwayland->width;
pbox->height = pWindow->m_uSurface.xwayland->height;
}
- } else
- wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, pbox);
+ } else {
+ wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, pbox->pWlr());
+ pbox->applyFromWlr();
+ }
}
std::string CHyprXWaylandManager::getTitle(CWindow* pWindow) {
diff --git a/src/managers/XWaylandManager.hpp b/src/managers/XWaylandManager.hpp
index 807f0593..e41313e0 100644
--- a/src/managers/XWaylandManager.hpp
+++ b/src/managers/XWaylandManager.hpp
@@ -15,7 +15,7 @@ class CHyprXWaylandManager {
wlr_surface* getWindowSurface(CWindow*);
void activateSurface(wlr_surface*, bool);
void activateWindow(CWindow*, bool);
- void getGeometryForWindow(CWindow*, wlr_box*);
+ void getGeometryForWindow(CWindow*, CBox*);
std::string getTitle(CWindow*);
std::string getAppIDClass(CWindow*);
void sendCloseWindow(CWindow*);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index dcbf4e3c..d7733e96 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -599,8 +599,8 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
// TODO detect click on LS properly
if (*PRESIZEONBORDER && !m_bLastFocusOnLS) {
if (w && !w->m_bIsFullscreen) {
- const wlr_box real = {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(&real, mouseCoords.x, mouseCoords.y) || w->isInCurvedCorner(mouseCoords.x, mouseCoords.y)) && !w->hasPopupAt(mouseCoords)) {
+ const CBox real = {w->m_vRealPosition.vec().x, w->m_vRealPosition.vec().y, w->m_vRealSize.vec().x, w->m_vRealSize.vec().y};
+ if ((!real.containsPoint(mouseCoords) || w->isInCurvedCorner(mouseCoords.x, mouseCoords.y)) && !w->hasPopupAt(mouseCoords)) {
g_pKeybindManager->resizeWithBorder(e);
return;
}
@@ -675,8 +675,8 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
const auto pWindow = g_pCompositor->vectorToWindowIdeal(MOUSECOORDS);
if (*PGROUPBARSCROLLING && pWindow && !pWindow->m_bIsFullscreen && !pWindow->hasPopupAt(MOUSECOORDS) && pWindow->m_sGroupData.pNextWindow) {
- const wlr_box box = pWindow->getDecorationByType(DECORATION_GROUPBAR)->getWindowDecorationRegion().getExtents();
- if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) {
+ const CBox box = pWindow->getDecorationByType(DECORATION_GROUPBAR)->getWindowDecorationRegion().getExtents();
+ if (box.containsPoint(MOUSECOORDS)) {
if (e->delta > 0)
pWindow->setGroupCurrent(pWindow->m_sGroupData.pNextWindow);
else
@@ -1207,7 +1207,7 @@ void CInputManager::updateDragIcon() {
switch (m_sDrag.dragIcon->drag->grab_type) {
case WLR_DRAG_GRAB_KEYBOARD: break;
case WLR_DRAG_GRAB_KEYBOARD_POINTER: {
- wlr_box box = {m_sDrag.pos.x - 2, m_sDrag.pos.y - 2, m_sDrag.dragIcon->surface->current.width + 4, m_sDrag.dragIcon->surface->current.height + 4};
+ CBox box = {m_sDrag.pos.x - 2, m_sDrag.pos.y - 2, m_sDrag.dragIcon->surface->current.width + 4, m_sDrag.dragIcon->surface->current.height + 4};
g_pHyprRenderer->damageBox(&box);
m_sDrag.pos = getMouseCoordsInternal();
break;
@@ -1474,9 +1474,9 @@ void CInputManager::setTabletConfigs() {
const auto REGION_POS = g_pConfigManager->getDeviceVec(t.name, "region_position", "input:tablet:region_position");
const auto REGION_SIZE = g_pConfigManager->getDeviceVec(t.name, "region_size", "input:tablet:region_size");
- const auto REGION = wlr_box{REGION_POS.x, REGION_POS.y, REGION_SIZE.x, REGION_SIZE.y};
- if (!wlr_box_empty(&REGION))
- wlr_cursor_map_input_to_region(g_pCompositor->m_sWLRCursor, t.wlrDevice, &REGION);
+ auto regionBox = CBox{REGION_POS.x, REGION_POS.y, REGION_SIZE.x, REGION_SIZE.y};
+ if (!regionBox.empty())
+ wlr_cursor_map_input_to_region(g_pCompositor->m_sWLRCursor, t.wlrDevice, regionBox.pWlr());
}
}
}
@@ -1621,14 +1621,14 @@ void CInputManager::setCursorIconOnBorder(CWindow* w) {
// give a small leeway (10 px) for corner icon
const auto CORNER = *PROUNDING + BORDERSIZE + 10;
const auto mouseCoords = getMouseCoordsInternal();
- wlr_box box = w->getWindowMainSurfaceBox();
+ CBox box = w->getWindowMainSurfaceBox();
eBorderIconDirection direction = BORDERICON_NONE;
- wlr_box boxFullGrabInput = {box.x - *PEXTENDBORDERGRAB - BORDERSIZE, box.y - *PEXTENDBORDERGRAB - BORDERSIZE, box.width + 2 * (*PEXTENDBORDERGRAB + BORDERSIZE),
- box.height + 2 * (*PEXTENDBORDERGRAB + BORDERSIZE)};
+ CBox boxFullGrabInput = {box.x - *PEXTENDBORDERGRAB - BORDERSIZE, box.y - *PEXTENDBORDERGRAB - BORDERSIZE, box.width + 2 * (*PEXTENDBORDERGRAB + BORDERSIZE),
+ box.height + 2 * (*PEXTENDBORDERGRAB + BORDERSIZE)};
if (w->hasPopupAt(mouseCoords))
direction = BORDERICON_NONE;
- else if (!wlr_box_contains_point(&boxFullGrabInput, mouseCoords.x, mouseCoords.y) || (!m_lCurrentlyHeldButtons.empty() && !currentlyDraggedWindow))
+ else if (!boxFullGrabInput.containsPoint(mouseCoords) || (!m_lCurrentlyHeldButtons.empty() && !currentlyDraggedWindow))
direction = BORDERICON_NONE;
else {
@@ -1647,7 +1647,7 @@ void CInputManager::setCursorIconOnBorder(CWindow* w) {
if (onDeco)
direction = BORDERICON_NONE;
else {
- if (wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y)) {
+ if (box.containsPoint(mouseCoords)) {
if (!w->isInCurvedCorner(mouseCoords.x, mouseCoords.y)) {
direction = BORDERICON_NONE;
} else {
diff --git a/src/managers/input/InputMethodRelay.cpp b/src/managers/input/InputMethodRelay.cpp
index 4af17096..5b6df08d 100644
--- a/src/managers/input/InputMethodRelay.cpp
+++ b/src/managers/input/InputMethodRelay.cpp
@@ -178,7 +178,7 @@ void CInputMethodRelay::updateInputPopup(SIMEPopup* pPopup) {
bool cursorRect = PFOCUSEDTI->pWlrInput ? PFOCUSEDTI->pWlrInput->current.features & WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE : true;
const auto PFOCUSEDSURFACE = focusedSurface(PFOCUSEDTI);
- auto cursorBox = PFOCUSEDTI->pWlrInput ? PFOCUSEDTI->pWlrInput->current.cursor_rectangle : PFOCUSEDTI->pV1Input->cursorRectangle;
+ CBox cursorBox = PFOCUSEDTI->pWlrInput ? PFOCUSEDTI->pWlrInput->current.cursor_rectangle : PFOCUSEDTI->pV1Input->cursorRectangle;
CMonitor* pMonitor = nullptr;
Vector2D parentPos;
@@ -209,7 +209,7 @@ void CInputMethodRelay::updateInputPopup(SIMEPopup* pPopup) {
if (!pMonitor)
return;
- wlr_box finalBox = cursorBox;
+ CBox finalBox = cursorBox;
if (cursorBox.y + parentPos.y + pPopup->pSurface->surface->current.height + finalBox.height > pMonitor->vecPosition.y + pMonitor->vecSize.y)
finalBox.y -= pPopup->pSurface->surface->current.height + finalBox.height;
@@ -225,7 +225,7 @@ void CInputMethodRelay::updateInputPopup(SIMEPopup* pPopup) {
pPopup->lastSize = Vector2D(pPopup->pSurface->surface->current.width, pPopup->pSurface->surface->current.height);
- wlr_input_popup_surface_v2_send_text_input_rectangle(pPopup->pSurface, &finalBox);
+ wlr_input_popup_surface_v2_send_text_input_rectangle(pPopup->pSurface, finalBox.pWlr());
damagePopup(pPopup);
}