Hyprbars: disable drag when clicking button (#289)

This commit is contained in:
elviosak 2025-02-03 16:50:03 -03:00 committed by GitHub
parent eefa87d099
commit 557e7b4e11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -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) {
@ -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;
@ -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) {

View file

@ -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();