Skip to content

Commit

Permalink
Hyprbars: disable drag when clicking button (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
elviosak authored Feb 3, 2025
1 parent eefa87d commit 557e7b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions hyprbars/barDeco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,8 @@ void CHyprBar::handleDownEvent(SCallbackInfo& info, std::optional<ITouch::SDownE
info.cancelled = true;
m_bCancelledDown = true;

doButtonPress(PBARPADDING, PBARBUTTONPADDING, PHEIGHT, COORDS, BUTTONSRIGHT);

m_bDragPending = true;
if (!doButtonPress(PBARPADDING, PBARBUTTONPADDING, PHEIGHT, COORDS, BUTTONSRIGHT))
m_bDragPending = true;
}

void CHyprBar::handleUpEvent(SCallbackInfo& info) {
Expand Down Expand Up @@ -194,7 +193,7 @@ void CHyprBar::handleMovement() {
return;
}

void CHyprBar::doButtonPress(long int* const* PBARPADDING, long int* const* PBARBUTTONPADDING, long int* const* PHEIGHT, Vector2D COORDS, const bool BUTTONSRIGHT) {
bool CHyprBar::doButtonPress(long int* const* PBARPADDING, long int* const* PBARBUTTONPADDING, long int* const* PHEIGHT, Vector2D COORDS, const bool BUTTONSRIGHT) {
//check if on a button
float offset = **PBARPADDING;

Expand All @@ -205,11 +204,12 @@ void CHyprBar::doButtonPress(long int* const* PBARPADDING, long int* const* PBAR
if (VECINRECT(COORDS, currentPos.x, currentPos.y, currentPos.x + b.size + **PBARBUTTONPADDING, currentPos.y + b.size)) {
// hit on close
g_pKeybindManager->m_mDispatchers["exec"](b.cmd);
return;
return true;
}

offset += **PBARBUTTONPADDING + b.size;
}
return false;
}

void CHyprBar::renderText(SP<CTexture> out, const std::string& text, const CHyprColor& color, const Vector2D& bufferSize, const float scale, const int fontSize) {
Expand Down
2 changes: 1 addition & 1 deletion hyprbars/barDeco.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CHyprBar : public IHyprWindowDecoration {
void handleDownEvent(SCallbackInfo& info, std::optional<ITouch::SDownEvent> touchEvent);
void handleUpEvent(SCallbackInfo& info);
void handleMovement();
void doButtonPress(long int* const* PBARPADDING, long int* const* PBARBUTTONPADDING, long int* const* PHEIGHT, Vector2D COORDS, bool BUTTONSRIGHT);
bool doButtonPress(long int* const* PBARPADDING, long int* const* PBARBUTTONPADDING, long int* const* PHEIGHT, Vector2D COORDS, bool BUTTONSRIGHT);

CBox assignedBoxGlobal();

Expand Down

0 comments on commit 557e7b4

Please sign in to comment.