Skip to content

Commit

Permalink
refine logic
Browse files Browse the repository at this point in the history
  • Loading branch information
caffeine01 committed Dec 19, 2024
1 parent bedf9b6 commit 6ed6829
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
19 changes: 13 additions & 6 deletions src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#include "Monitor.hpp"
#include "../Hyprpaper.hpp"
#include "MiscFunctions.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);

//ensures any transforms are also taken care of when setting the mode
if (transform & 1)
std::swap(size.x, size.y);
});

output->setDone([this](CCWlOutput* r) {
readyForLS = true;
Expand All @@ -25,12 +32,12 @@ 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_) { //
/*
see https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
IF { (new transform event IS by 90n degrees) AND (old transform event was NOT by 90n degrees) }
THEN { swap the size vector accordingly. }
see https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
If there is a difference in parity of the old vs new transforms, the size needs to be swapped.
*/
if (((transform_ % 4) == 1 || (transform_ % 4) == 3) && ((transform % 4) != 1 || (transform % 4) != 3))
if ((transform ^ transform_) & 1)
std::swap(size.x, size.y);

transform = (wl_output_transform)transform_;
});
}
}
7 changes: 3 additions & 4 deletions src/helpers/Monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ struct SMonitor {
uint32_t configureSerial = 0;
SPoolBuffer buffer;

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
bool wantsReload = false;
bool wantsACK = false;
bool initialized = false;

std::vector<std::unique_ptr<CLayerSurface>> layerSurfaces;
CLayerSurface* pCurrentLayerSurface = nullptr;
Expand Down

0 comments on commit 6ed6829

Please sign in to comment.