From 3b44ce9725286064e62d4b0e424f270058375478 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 16 Mar 2023 16:00:59 +0000 Subject: [PATCH] hyprbars: minor drag fixes --- hyprbars/barDeco.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index 0009afc..7a451a7 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -40,7 +40,15 @@ void CHyprBar::onMouseDown(wlr_pointer_button_event* e) { if (m_pWindow != g_pCompositor->m_pLastWindow) return; - const auto COORDS = cursorRelativeToBar(); + const auto COORDS = cursorRelativeToBar(); + + static auto* const PHEIGHT = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->intValue; + + if (!VECINRECT(COORDS, 0, 0, m_vLastWindowSize.x, *PHEIGHT)) { + m_bDraggingThis = false; + m_bDragPending = false; + return; + } if (e->state != WLR_BUTTON_PRESSED) { if (m_bDraggingThis) { @@ -55,7 +63,6 @@ void CHyprBar::onMouseDown(wlr_pointer_button_event* e) { // check if on a button static auto* const PBORDERSIZE = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue; - static auto* const PHEIGHT = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->intValue; const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * *PBORDERSIZE, *PHEIGHT}; Vector2D currentPos = Vector2D{BARBUF.x - BUTTONS_PAD - BUTTONS_SIZE, BARBUF.y / 2.0 - BUTTONS_SIZE / 2.0}.floor(); currentPos.y -= BUTTONS_PAD / 2.0; @@ -76,13 +83,7 @@ void CHyprBar::onMouseDown(wlr_pointer_button_event* e) { return; } - // if we call da dispatcher here the handler later will remove our mouse bind - if (VECINRECT(COORDS, 0, 0, m_vLastWindowSize.x, *PHEIGHT)) - m_bDragPending = true; - else { - m_bDraggingThis = false; - m_bDragPending = false; - } + m_bDragPending = true; } void CHyprBar::onMouseMove(Vector2D coords) {