Skip to content

Commit

Permalink
chore: minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bk304 committed Feb 19, 2025
1 parent 40cbcbf commit 3fe7571
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
25 changes: 3 additions & 22 deletions src/protocols/PointerConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ void CPointerConstraint::sharedConstructions() {
}

cursorPosOnActivate = g_pInputManager->getMouseCoordsInternal();

if (g_pCompositor->m_pLastFocus == pHLSurface->resource())
activate();
}

bool CPointerConstraint::good() {
Expand All @@ -111,8 +108,7 @@ void CPointerConstraint::deactivate() {
else
resourceC->sendUnconfined();

pendingActivation = false;
active = false;
active = false;

if (lifetime == ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT) {
dead = true;
Expand All @@ -128,13 +124,7 @@ void CPointerConstraint::activate() {
if (dead || active)
return;

if (!attached) {
pendingActivation = true;
return;
}
pendingActivation = false;

//TODO: hack, probably not a super duper great idea
// TODO: hack, probably not a super duper great idea
if (g_pSeatManager->state.pointerFocus != pHLSurface->resource()) {
const auto SURFBOX = pHLSurface->getSurfaceBoxGlobal();
const auto LOCAL = SURFBOX.has_value() ? logicPositionHint() - SURFBOX->pos() : Vector2D{};
Expand All @@ -155,14 +145,6 @@ bool CPointerConstraint::isActive() {
return active;
}

void CPointerConstraint::setAttached() {
attached = true;
}

bool CPointerConstraint::isActivationPending() {
return pendingActivation;
}

void CPointerConstraint::onSetRegion(wl_resource* wlRegion) {
if (!wlRegion) {
region.clear();
Expand Down Expand Up @@ -260,8 +242,7 @@ void CPointerConstraintsProtocol::onNewConstraint(SP<CPointerConstraint> constra

g_pInputManager->m_vConstraints.emplace_back(constraint);

constraint->setAttached();
if (constraint->isActivationPending())
if (g_pCompositor->m_pLastFocus == OWNER->resource())
constraint->activate();
}

Expand Down
7 changes: 1 addition & 6 deletions src/protocols/PointerConstraints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class CPointerConstraint {
void activate();
bool isActive();

void setAttached();
bool isActivationPending();

SP<CWLSurface> owner();

CRegion logicConstraintRegion();
Expand All @@ -45,8 +42,6 @@ class CPointerConstraint {
Vector2D positionHint = {-1, -1};
Vector2D cursorPosOnActivate = {-1, -1};
bool active = false;
bool attached = false;
bool pendingActivation = false;
bool locked = false;
bool dead = false;
zwpPointerConstraintsV1Lifetime lifetime = ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT;
Expand Down Expand Up @@ -81,4 +76,4 @@ class CPointerConstraintsProtocol : public IWaylandProtocol {

namespace PROTO {
inline UP<CPointerConstraintsProtocol> constraints;
};
};

0 comments on commit 3fe7571

Please sign in to comment.