ensure transforms are unique and relevant before swapping resolution

This commit is contained in:
caffeine01 2024-12-19 00:04:24 +00:00
parent ecab9e7291
commit 561cb583da
2 changed files with 16 additions and 5 deletions

View file

@ -2,7 +2,10 @@
#include "../Hyprpaper.hpp"
void SMonitor::registerListeners() {
output->setMode([this](CCWlOutput* r, uint32_t flags, int32_t width, int32_t height, int32_t refresh) { size = Vector2D(width, height); });
output->setMode([this](CCWlOutput* r, uint32_t flags, int32_t width, int32_t height, int32_t refresh) {
size = Vector2D(width, height);
newModeForGeometry = true;
});
output->setDone([this](CCWlOutput* r) {
readyForLS = true;
@ -25,7 +28,14 @@ void SMonitor::registerListeners() {
output->setGeometry([this](CCWlOutput* r, int32_t x, int32_t y, int32_t width_mm, int32_t height_mm, int32_t subpixel, const char* make, const char* model,
int32_t transform_) { //
transform = (wl_output_transform)transform_;
if (transform == WL_OUTPUT_TRANSFORM_90 || transform == WL_OUTPUT_TRANSFORM_270)
//if no new mode has been sent before a geometry request, ignore it.
if (!newModeForGeometry)
return;
newModeForGeometry = false;
//see https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
if ((transform % 4) == 1 || (transform % 4) == 3)
std::swap(size.x, size.y);
});
}

View file

@ -22,9 +22,10 @@ struct SMonitor {
uint32_t configureSerial = 0;
SPoolBuffer buffer;
bool wantsReload = false;
bool wantsACK = false;
bool initialized = false;
bool wantsReload = false;
bool wantsACK = false;
bool initialized = false;
bool newModeForGeometry = false; //used to ensure mode has been set/changed before handling new geometry events
std::vector<std::unique_ptr<CLayerSurface>> layerSurfaces;
CLayerSurface* pCurrentLayerSurface = nullptr;