Skip to content

Commit 6ed6829

Browse files
committed
refine logic
1 parent bedf9b6 commit 6ed6829

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/helpers/Monitor.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#include "Monitor.hpp"
22
#include "../Hyprpaper.hpp"
3+
#include "MiscFunctions.hpp"
34

45
void SMonitor::registerListeners() {
5-
output->setMode([this](CCWlOutput* r, uint32_t flags, int32_t width, int32_t height, int32_t refresh) { size = Vector2D(width, height); });
6+
output->setMode([this](CCWlOutput* r, uint32_t flags, int32_t width, int32_t height, int32_t refresh) {
7+
size = Vector2D(width, height);
8+
9+
//ensures any transforms are also taken care of when setting the mode
10+
if (transform & 1)
11+
std::swap(size.x, size.y);
12+
});
613

714
output->setDone([this](CCWlOutput* r) {
815
readyForLS = true;
@@ -25,12 +32,12 @@ void SMonitor::registerListeners() {
2532
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,
2633
int32_t transform_) { //
2734
/*
28-
see https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
29-
IF { (new transform event IS by 90n degrees) AND (old transform event was NOT by 90n degrees) }
30-
THEN { swap the size vector accordingly. }
35+
see https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_output-enum-transform
36+
If there is a difference in parity of the old vs new transforms, the size needs to be swapped.
3137
*/
32-
if (((transform_ % 4) == 1 || (transform_ % 4) == 3) && ((transform % 4) != 1 || (transform % 4) != 3))
38+
if ((transform ^ transform_) & 1)
3339
std::swap(size.x, size.y);
40+
3441
transform = (wl_output_transform)transform_;
3542
});
36-
}
43+
}

src/helpers/Monitor.hpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ struct SMonitor {
2222
uint32_t configureSerial = 0;
2323
SPoolBuffer buffer;
2424

25-
bool wantsReload = false;
26-
bool wantsACK = false;
27-
bool initialized = false;
28-
bool newModeForGeometry = false; //used to ensure mode has been set/changed before handling new geometry events
25+
bool wantsReload = false;
26+
bool wantsACK = false;
27+
bool initialized = false;
2928

3029
std::vector<std::unique_ptr<CLayerSurface>> layerSurfaces;
3130
CLayerSurface* pCurrentLayerSurface = nullptr;

0 commit comments

Comments
 (0)