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
				
			
		| 
						 | 
				
			
			@ -184,33 +184,35 @@ void PopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bool only
 | 
			
		|||
	auto effectiveY = calcEffectiveY();
 | 
			
		||||
 | 
			
		||||
	if (adjustment.testFlag(PopupAdjustment::FlipX)) {
 | 
			
		||||
		if (anchorGravity.testFlag(Edges::Left)) {
 | 
			
		||||
			if (effectiveX < screenGeometry.left()) {
 | 
			
		||||
				anchorGravity = anchorGravity ^ Edges::Left | Edges::Right;
 | 
			
		||||
				anchorX = anchorRectGeometry.right();
 | 
			
		||||
		bool flip = (anchorGravity.testFlag(Edges::Left) && effectiveX < screenGeometry.left())
 | 
			
		||||
		         || (anchorGravity.testFlag(Edges::Right)
 | 
			
		||||
		             && effectiveX + windowGeometry.width() > screenGeometry.right());
 | 
			
		||||
 | 
			
		||||
		if (flip) {
 | 
			
		||||
			anchorGravity ^= Edges::Left | Edges::Right;
 | 
			
		||||
 | 
			
		||||
			anchorX = anchorEdges.testFlags(Edges::Left)  ? anchorRectGeometry.right()
 | 
			
		||||
			        : anchorEdges.testFlags(Edges::Right) ? anchorRectGeometry.left()
 | 
			
		||||
			                                              : anchorX;
 | 
			
		||||
 | 
			
		||||
			effectiveX = calcEffectiveX();
 | 
			
		||||
		}
 | 
			
		||||
		} else if (anchorGravity.testFlag(Edges::Right)) {
 | 
			
		||||
			if (effectiveX + windowGeometry.width() > screenGeometry.right()) {
 | 
			
		||||
				anchorGravity = anchorGravity ^ Edges::Right | Edges::Left;
 | 
			
		||||
				anchorX = anchorRectGeometry.left();
 | 
			
		||||
				effectiveX = calcEffectiveX();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (adjustment.testFlag(PopupAdjustment::FlipY)) {
 | 
			
		||||
		if (anchorGravity.testFlag(Edges::Top)) {
 | 
			
		||||
			if (effectiveY < screenGeometry.top()) {
 | 
			
		||||
				anchorGravity = anchorGravity ^ Edges::Top | Edges::Bottom;
 | 
			
		||||
		bool flip = (anchorGravity.testFlag(Edges::Top) && effectiveY < screenGeometry.top())
 | 
			
		||||
		         || (anchorGravity.testFlag(Edges::Bottom)
 | 
			
		||||
		             && effectiveY + windowGeometry.height() > screenGeometry.bottom());
 | 
			
		||||
 | 
			
		||||
		if (flip) {
 | 
			
		||||
			anchorGravity ^= Edges::Top | Edges::Bottom;
 | 
			
		||||
 | 
			
		||||
			anchorY = anchorEdges.testFlags(Edges::Top)    ? anchorRectGeometry.bottom()
 | 
			
		||||
			        : anchorEdges.testFlags(Edges::Bottom) ? anchorRectGeometry.top()
 | 
			
		||||
			                                               : anchorY;
 | 
			
		||||
 | 
			
		||||
			effectiveY = calcEffectiveY();
 | 
			
		||||
		}
 | 
			
		||||
		} else if (anchorGravity.testFlag(Edges::Bottom)) {
 | 
			
		||||
			if (effectiveY + windowGeometry.height() > screenGeometry.bottom()) {
 | 
			
		||||
				anchorGravity = anchorGravity ^ Edges::Bottom | Edges::Top;
 | 
			
		||||
				effectiveY = calcEffectiveY();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Slide order is important for the case where the window is too large to fit on screen.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue