From 5908a95ef25f2f089182e92346f017303205dc58 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Wed, 11 Jan 2023 06:04:53 +0100 Subject: [PATCH] add clickable border --- src/Compositor.cpp | 12 ++++++++---- src/managers/input/InputManager.cpp | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 6b72465d..62c2feac 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -560,12 +560,14 @@ void findExtensionForVector2D(wlr_surface* surface, int x, int y, void* data) { } CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) { - const auto PMONITOR = getMonitorFromVector(pos); + const auto PMONITOR = getMonitorFromVector(pos); + const auto FOCUS_EXTENT = g_pConfigManager->getConfigValuePtr("general:resize_on_gaps")->intValue ? g_pConfigManager->getConfigValuePtr("general:border_size")->intValue : 0; // special workspace if (PMONITOR->specialWorkspaceID) { 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 - FOCUS_EXTENT, (*w)->m_vRealPosition.vec().y - FOCUS_EXTENT, (*w)->m_vRealSize.vec().x + 2 * FOCUS_EXTENT, + (*w)->m_vRealSize.vec().y + 2 * FOCUS_EXTENT}; if ((*w)->m_bIsFloating && (*w)->m_iWorkspaceID == PMONITOR->specialWorkspaceID && (*w)->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !(*w)->isHidden() && !(*w)->m_bX11ShouldntFocus) return (*w).get(); @@ -581,7 +583,8 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) { // pinned windows on top of floating regardless 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 - FOCUS_EXTENT, (*w)->m_vRealPosition.vec().y - FOCUS_EXTENT, (*w)->m_vRealSize.vec().x + 2 * FOCUS_EXTENT, + (*w)->m_vRealSize.vec().y + 2 * FOCUS_EXTENT}; 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)) return w->get(); @@ -600,7 +603,8 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) { // 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++) { - 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 - FOCUS_EXTENT, (*w)->m_vRealPosition.vec().y - FOCUS_EXTENT, (*w)->m_vRealSize.vec().x + 2 * FOCUS_EXTENT, + (*w)->m_vRealSize.vec().y + 2 * FOCUS_EXTENT}; if ((*w)->m_bIsFloating && (*w)->m_bIsMapped && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden() && !(*w)->m_bPinned) { // OR windows should add focus to parent if ((*w)->m_bX11ShouldntFocus && (*w)->m_iX11Type != 2) diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index b7d3b499..88ed9a94 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -39,6 +39,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { static auto* const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue; static auto* const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue; static auto* const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue; + const auto FOCUS_EXTENT = g_pConfigManager->getConfigValuePtr("general:resize_on_gaps")->intValue ? g_pConfigManager->getConfigValuePtr("general:border_size")->intValue : 0; m_pFoundSurfaceToFocus = nullptr; m_pFoundLSToFocus = nullptr; @@ -158,7 +159,8 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { // only check floating because tiled cant be over fullscreen 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 - FOCUS_EXTENT, (*w)->m_vRealPosition.vec().y - FOCUS_EXTENT, (*w)->m_vRealSize.vec().x + 2 * FOCUS_EXTENT, + (*w)->m_vRealSize.vec().y + 2 * FOCUS_EXTENT}; if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && ((*w)->m_bCreatedOverFullscreen || (*w)->m_bPinned)) || (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()) {