forked from quickshell/quickshell
		
	core/popupanchor: fix flip with opposite anchors and gravity
Flips into the anchor rect instead of over it when anchors and gravity are opposite.
This commit is contained in:
		
							parent
							
								
									60388f10ca
								
							
						
					
					
						commit
						a71a6fb3ac
					
				
					 1 changed files with 26 additions and 24 deletions
				
			
		| 
						 | 
					@ -12,8 +12,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool PopupAnchorState::operator==(const PopupAnchorState& other) const {
 | 
					bool PopupAnchorState::operator==(const PopupAnchorState& other) const {
 | 
				
			||||||
	return this->rect == other.rect && this->edges == other.edges && this->gravity == other.gravity
 | 
						return this->rect == other.rect && this->edges == other.edges && this->gravity == other.gravity
 | 
				
			||||||
			&& this->adjustment == other.adjustment && this->anchorpoint == other.anchorpoint
 | 
						    && this->adjustment == other.adjustment && this->anchorpoint == other.anchorpoint
 | 
				
			||||||
			&& this->size == other.size;
 | 
						    && this->size == other.size;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool PopupAnchor::isDirty() const {
 | 
					bool PopupAnchor::isDirty() const {
 | 
				
			||||||
| 
						 | 
					@ -184,32 +184,34 @@ void PopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bool only
 | 
				
			||||||
	auto effectiveY = calcEffectiveY();
 | 
						auto effectiveY = calcEffectiveY();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (adjustment.testFlag(PopupAdjustment::FlipX)) {
 | 
						if (adjustment.testFlag(PopupAdjustment::FlipX)) {
 | 
				
			||||||
		if (anchorGravity.testFlag(Edges::Left)) {
 | 
							bool flip = (anchorGravity.testFlag(Edges::Left) && effectiveX < screenGeometry.left())
 | 
				
			||||||
			if (effectiveX < screenGeometry.left()) {
 | 
							         || (anchorGravity.testFlag(Edges::Right)
 | 
				
			||||||
				anchorGravity = anchorGravity ^ Edges::Left | Edges::Right;
 | 
							             && effectiveX + windowGeometry.width() > screenGeometry.right());
 | 
				
			||||||
				anchorX = anchorRectGeometry.right();
 | 
					
 | 
				
			||||||
				effectiveX = calcEffectiveX();
 | 
							if (flip) {
 | 
				
			||||||
			}
 | 
								anchorGravity ^= Edges::Left | Edges::Right;
 | 
				
			||||||
		} else if (anchorGravity.testFlag(Edges::Right)) {
 | 
					
 | 
				
			||||||
			if (effectiveX + windowGeometry.width() > screenGeometry.right()) {
 | 
								anchorX = anchorEdges.testFlags(Edges::Left)  ? anchorRectGeometry.right()
 | 
				
			||||||
				anchorGravity = anchorGravity ^ Edges::Right | Edges::Left;
 | 
								        : anchorEdges.testFlags(Edges::Right) ? anchorRectGeometry.left()
 | 
				
			||||||
				anchorX = anchorRectGeometry.left();
 | 
								                                              : anchorX;
 | 
				
			||||||
				effectiveX = calcEffectiveX();
 | 
					
 | 
				
			||||||
			}
 | 
								effectiveX = calcEffectiveX();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (adjustment.testFlag(PopupAdjustment::FlipY)) {
 | 
						if (adjustment.testFlag(PopupAdjustment::FlipY)) {
 | 
				
			||||||
		if (anchorGravity.testFlag(Edges::Top)) {
 | 
							bool flip = (anchorGravity.testFlag(Edges::Top) && effectiveY < screenGeometry.top())
 | 
				
			||||||
			if (effectiveY < screenGeometry.top()) {
 | 
							         || (anchorGravity.testFlag(Edges::Bottom)
 | 
				
			||||||
				anchorGravity = anchorGravity ^ Edges::Top | Edges::Bottom;
 | 
							             && effectiveY + windowGeometry.height() > screenGeometry.bottom());
 | 
				
			||||||
				effectiveY = calcEffectiveY();
 | 
					
 | 
				
			||||||
			}
 | 
							if (flip) {
 | 
				
			||||||
		} else if (anchorGravity.testFlag(Edges::Bottom)) {
 | 
								anchorGravity ^= Edges::Top | Edges::Bottom;
 | 
				
			||||||
			if (effectiveY + windowGeometry.height() > screenGeometry.bottom()) {
 | 
					
 | 
				
			||||||
				anchorGravity = anchorGravity ^ Edges::Bottom | Edges::Top;
 | 
								anchorY = anchorEdges.testFlags(Edges::Top)    ? anchorRectGeometry.bottom()
 | 
				
			||||||
				effectiveY = calcEffectiveY();
 | 
								        : anchorEdges.testFlags(Edges::Bottom) ? anchorRectGeometry.top()
 | 
				
			||||||
			}
 | 
								                                               : anchorY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								effectiveY = calcEffectiveY();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue