forked from quickshell/quickshell
		
	wayland/all: scale layers and popup anchors correctly
Layers now scale window size and exclusive zone to native pixels. Popup anchors do the same.
This commit is contained in:
		
							parent
							
								
									293341c9e1
								
							
						
					
					
						commit
						accdc59a1c
					
				
					 2 changed files with 23 additions and 3 deletions
				
			
		| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
#include "popupanchor.hpp"
 | 
					#include "popupanchor.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <private/qhighdpiscaling_p.h>
 | 
				
			||||||
#include <private/qwayland-xdg-shell.h>
 | 
					#include <private/qwayland-xdg-shell.h>
 | 
				
			||||||
#include <private/qwaylandwindow_p.h>
 | 
					#include <private/qwaylandwindow_p.h>
 | 
				
			||||||
#include <private/wayland-xdg-shell-client-protocol.h>
 | 
					#include <private/wayland-xdg-shell-client-protocol.h>
 | 
				
			||||||
| 
						 | 
					@ -41,6 +42,14 @@ void WaylandPopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bo
 | 
				
			||||||
		positioner.set_constraint_adjustment(anchor->adjustment().toInt());
 | 
							positioner.set_constraint_adjustment(anchor->adjustment().toInt());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		auto anchorRect = anchor->rect();
 | 
							auto anchorRect = anchor->rect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (auto* p = window->transientParent()) {
 | 
				
			||||||
 | 
								anchorRect.x = QHighDpi::toNativePixels(anchorRect.x, p);
 | 
				
			||||||
 | 
								anchorRect.y = QHighDpi::toNativePixels(anchorRect.y, p);
 | 
				
			||||||
 | 
								anchorRect.w = QHighDpi::toNativePixels(anchorRect.w, p);
 | 
				
			||||||
 | 
								anchorRect.h = QHighDpi::toNativePixels(anchorRect.h, p);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		positioner.set_anchor_rect(anchorRect.x, anchorRect.y, anchorRect.w, anchorRect.h);
 | 
							positioner.set_anchor_rect(anchorRect.x, anchorRect.y, anchorRect.w, anchorRect.h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		XdgPositioner::anchor anchorFlag = XdgPositioner::anchor_none;
 | 
							XdgPositioner::anchor anchorFlag = XdgPositioner::anchor_none;
 | 
				
			||||||
| 
						 | 
					@ -92,9 +101,18 @@ void WaylandPopupPositioner::reposition(PopupAnchor* anchor, QWindow* window, bo
 | 
				
			||||||
bool WaylandPopupPositioner::shouldRepositionOnMove() const { return true; }
 | 
					bool WaylandPopupPositioner::shouldRepositionOnMove() const { return true; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WaylandPopupPositioner::setFlags(PopupAnchor* anchor, QWindow* window) {
 | 
					void WaylandPopupPositioner::setFlags(PopupAnchor* anchor, QWindow* window) {
 | 
				
			||||||
 | 
						auto anchorRect = anchor->rect();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (auto* p = window->transientParent()) {
 | 
				
			||||||
 | 
							anchorRect.x = QHighDpi::toNativePixels(anchorRect.x, p);
 | 
				
			||||||
 | 
							anchorRect.y = QHighDpi::toNativePixels(anchorRect.y, p);
 | 
				
			||||||
 | 
							anchorRect.w = QHighDpi::toNativePixels(anchorRect.w, p);
 | 
				
			||||||
 | 
							anchorRect.h = QHighDpi::toNativePixels(anchorRect.h, p);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// clang-format off
 | 
						// clang-format off
 | 
				
			||||||
	window->setProperty("_q_waylandPopupConstraintAdjustment", anchor->adjustment().toInt());
 | 
						window->setProperty("_q_waylandPopupConstraintAdjustment", anchor->adjustment().toInt());
 | 
				
			||||||
	window->setProperty("_q_waylandPopupAnchorRect", anchor->rect().qrect());
 | 
						window->setProperty("_q_waylandPopupAnchorRect", anchorRect.qrect());
 | 
				
			||||||
	window->setProperty("_q_waylandPopupAnchor", QVariant::fromValue(Edges::toQt(anchor->edges())));
 | 
						window->setProperty("_q_waylandPopupAnchor", QVariant::fromValue(Edges::toQt(anchor->edges())));
 | 
				
			||||||
	window->setProperty("_q_waylandPopupGravity", QVariant::fromValue(Edges::toQt(anchor->gravity())));
 | 
						window->setProperty("_q_waylandPopupGravity", QVariant::fromValue(Edges::toQt(anchor->gravity())));
 | 
				
			||||||
	// clang-format on
 | 
						// clang-format on
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
#include "surface.hpp"
 | 
					#include "surface.hpp"
 | 
				
			||||||
#include <any>
 | 
					#include <any>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <private/qhighdpiscaling_p.h>
 | 
				
			||||||
#include <private/qwaylanddisplay_p.h>
 | 
					#include <private/qwaylanddisplay_p.h>
 | 
				
			||||||
#include <private/qwaylandscreen_p.h>
 | 
					#include <private/qwaylandscreen_p.h>
 | 
				
			||||||
#include <private/qwaylandshellsurface_p.h>
 | 
					#include <private/qwaylandshellsurface_p.h>
 | 
				
			||||||
| 
						 | 
					@ -70,7 +71,7 @@ QSWaylandLayerSurface::QSWaylandLayerSurface(
 | 
				
			||||||
	// new updates will be sent from the extension
 | 
						// new updates will be sent from the extension
 | 
				
			||||||
	this->ext->surface = this;
 | 
						this->ext->surface = this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto size = constrainedSize(this->ext->mAnchors, qwindow->size());
 | 
						auto size = constrainedSize(this->ext->mAnchors, window->surfaceSize());
 | 
				
			||||||
	this->set_size(size.width(), size.height());
 | 
						this->set_size(size.width(), size.height());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -137,7 +138,8 @@ void QSWaylandLayerSurface::updateMargins() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QSWaylandLayerSurface::updateExclusiveZone() {
 | 
					void QSWaylandLayerSurface::updateExclusiveZone() {
 | 
				
			||||||
	this->set_exclusive_zone(this->ext->mExclusiveZone);
 | 
						auto nativeZone = QHighDpi::toNativePixels(this->ext->mExclusiveZone, this->window()->window());
 | 
				
			||||||
 | 
						this->set_exclusive_zone(nativeZone);
 | 
				
			||||||
	this->window()->waylandSurface()->commit();
 | 
						this->window()->waylandSurface()->commit();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue