mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 07:45:59 +01:00
core: Move to hyprutils for Math
Moves CRegion, CBox and Vector2D over to hyprutils. Requires hyprutils>=0.1.4
This commit is contained in:
parent
6e5804b53d
commit
fb15b7aa2a
76 changed files with 509 additions and 1004 deletions
|
@ -113,7 +113,7 @@ pkg_check_modules(deps REQUIRED IMPORTED_TARGET
|
||||||
wayland-server wayland-client wayland-cursor wayland-protocols
|
wayland-server wayland-client wayland-cursor wayland-protocols
|
||||||
cairo pango pangocairo pixman-1
|
cairo pango pangocairo pixman-1
|
||||||
libdrm libinput hwdata libseat libdisplay-info libliftoff libudev gbm
|
libdrm libinput hwdata libseat libdisplay-info libliftoff libudev gbm
|
||||||
hyprlang>=0.3.2 hyprcursor>=0.1.7 hyprutils>=0.1.1
|
hyprlang>=0.3.2 hyprcursor>=0.1.7 hyprutils>=0.1.4
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(hyprwayland-scanner 0.3.10 REQUIRED)
|
find_package(hyprwayland-scanner 0.3.10 REQUIRED)
|
||||||
|
|
|
@ -1434,8 +1434,7 @@ PHLWINDOW CCompositor::getWindowInDirection(PHLWINDOW pWindow, char dir) {
|
||||||
if (!PMONITOR)
|
if (!PMONITOR)
|
||||||
return nullptr; // ??
|
return nullptr; // ??
|
||||||
|
|
||||||
const auto WINDOWIDEALBB = pWindow->m_bIsFullscreen ? wlr_box{(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y} :
|
const auto WINDOWIDEALBB = pWindow->m_bIsFullscreen ? CBox{PMONITOR->vecPosition, PMONITOR->vecSize} : pWindow->getWindowIdealBoundingBoxIgnoreReserved();
|
||||||
pWindow->getWindowIdealBoundingBoxIgnoreReserved();
|
|
||||||
|
|
||||||
const auto POSA = Vector2D(WINDOWIDEALBB.x, WINDOWIDEALBB.y);
|
const auto POSA = Vector2D(WINDOWIDEALBB.x, WINDOWIDEALBB.y);
|
||||||
const auto SIZEA = Vector2D(WINDOWIDEALBB.width, WINDOWIDEALBB.height);
|
const auto SIZEA = Vector2D(WINDOWIDEALBB.width, WINDOWIDEALBB.height);
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "helpers/Vector2D.hpp"
|
#include "helpers/math/Math.hpp"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <any>
|
||||||
|
#include <hyprutils/math/Box.hpp>
|
||||||
|
|
||||||
|
using namespace Hyprutils::Math;
|
||||||
|
|
||||||
enum eIcons {
|
enum eIcons {
|
||||||
ICON_WARNING = 0,
|
ICON_WARNING = 0,
|
||||||
|
@ -37,29 +41,6 @@ struct SCallbackInfo {
|
||||||
bool cancelled = false; /* on cancellable events, will cancel the event. */
|
bool cancelled = false; /* on cancellable events, will cancel the event. */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SWindowDecorationExtents {
|
|
||||||
Vector2D topLeft;
|
|
||||||
Vector2D bottomRight;
|
|
||||||
|
|
||||||
//
|
|
||||||
SWindowDecorationExtents operator*(const double& scale) const {
|
|
||||||
return SWindowDecorationExtents{topLeft * scale, bottomRight * scale};
|
|
||||||
}
|
|
||||||
|
|
||||||
SWindowDecorationExtents round() {
|
|
||||||
return {topLeft.round(), bottomRight.round()};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const SWindowDecorationExtents& other) const {
|
|
||||||
return topLeft == other.topLeft && bottomRight == other.bottomRight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addExtents(const SWindowDecorationExtents& other) {
|
|
||||||
topLeft = topLeft.getComponentMax(other.topLeft);
|
|
||||||
bottomRight = bottomRight.getComponentMax(other.bottomRight);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
enum eHyprCtlOutputFormat {
|
enum eHyprCtlOutputFormat {
|
||||||
FORMAT_NORMAL = 0,
|
FORMAT_NORMAL = 0,
|
||||||
FORMAT_JSON
|
FORMAT_JSON
|
||||||
|
|
|
@ -982,7 +982,8 @@ float CConfigManager::getDeviceFloat(const std::string& dev, const std::string&
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D CConfigManager::getDeviceVec(const std::string& dev, const std::string& v, const std::string& fallback) {
|
Vector2D CConfigManager::getDeviceVec(const std::string& dev, const std::string& v, const std::string& fallback) {
|
||||||
return std::any_cast<Hyprlang::VEC2>(getConfigValueSafeDevice(dev, v, fallback)->getValue());
|
auto vec = std::any_cast<Hyprlang::VEC2>(getConfigValueSafeDevice(dev, v, fallback)->getValue());
|
||||||
|
return {vec.x, vec.y};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v, const std::string& fallback) {
|
std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v, const std::string& fallback) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
|
||||||
textW /= PANGO_SCALE;
|
textW /= PANGO_SCALE;
|
||||||
textH /= PANGO_SCALE;
|
textH /= PANGO_SCALE;
|
||||||
|
|
||||||
const auto NOTIFSIZE = Vector2D{textW + 20 + iconW + 2 * ICONPADFORNOTIF, textH + 10};
|
const auto NOTIFSIZE = Vector2D{textW + 20.0 + iconW + 2 * ICONPADFORNOTIF, textH + 10.0};
|
||||||
|
|
||||||
// draw rects
|
// draw rects
|
||||||
cairo_set_source_rgba(m_pCairo, notif->color.r, notif->color.g, notif->color.b, notif->color.a);
|
cairo_set_source_rgba(m_pCairo, notif->color.r, notif->color.g, notif->color.b, notif->color.a);
|
||||||
|
|
|
@ -412,9 +412,9 @@ void CLayerSurface::startAnimation(bool in, bool instant) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::array<Vector2D, 4> edgePoints = {
|
const std::array<Vector2D, 4> edgePoints = {
|
||||||
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x / 2, 0},
|
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x / 2, 0.0},
|
||||||
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x / 2, PMONITOR->vecSize.y},
|
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x / 2, PMONITOR->vecSize.y},
|
||||||
PMONITOR->vecPosition + Vector2D{0, PMONITOR->vecSize.y},
|
PMONITOR->vecPosition + Vector2D{0.0, PMONITOR->vecSize.y},
|
||||||
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x, PMONITOR->vecSize.y / 2},
|
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x, PMONITOR->vecSize.y / 2},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ CRegion CWLSurface::logicalDamage() const {
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
CRegion damage = m_pResource->accumulateCurrentBufferDamage();
|
CRegion damage = m_pResource->accumulateCurrentBufferDamage();
|
||||||
damage.transform(m_pResource->current.transform, m_pResource->current.buffer->size.x, m_pResource->current.buffer->size.y);
|
damage.transform(wlTransformToHyprutils(m_pResource->current.transform), m_pResource->current.buffer->size.x, m_pResource->current.buffer->size.y);
|
||||||
damage.scale(1.0 / m_pResource->current.scale);
|
damage.scale(1.0 / m_pResource->current.scale);
|
||||||
|
|
||||||
const auto VPSIZE = getViewporterCorrectedSize();
|
const auto VPSIZE = getViewporterCorrectedSize();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include "../helpers/Region.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/signal/Signal.hpp"
|
#include "../helpers/signal/Signal.hpp"
|
||||||
|
|
||||||
class CSubsurface;
|
class CSubsurface;
|
||||||
|
|
|
@ -104,7 +104,7 @@ CWindow::~CWindow() {
|
||||||
std::erase_if(g_pHyprOpenGL->m_mWindowFramebuffers, [&](const auto& other) { return !other.first.lock() || other.first.lock().get() == this; });
|
std::erase_if(g_pHyprOpenGL->m_mWindowFramebuffers, [&](const auto& other) { return !other.first.lock() || other.first.lock().get() == this; });
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents CWindow::getFullWindowExtents() {
|
SBoxExtents CWindow::getFullWindowExtents() {
|
||||||
if (m_bFadingOut)
|
if (m_bFadingOut)
|
||||||
return m_eOriginalClosedExtents;
|
return m_eOriginalClosedExtents;
|
||||||
|
|
||||||
|
@ -116,9 +116,9 @@ SWindowDecorationExtents CWindow::getFullWindowExtents() {
|
||||||
{PMONITOR->vecSize.x - (m_vRealPosition.value().x - PMONITOR->vecPosition.x), PMONITOR->vecSize.y - (m_vRealPosition.value().y - PMONITOR->vecPosition.y)}};
|
{PMONITOR->vecSize.x - (m_vRealPosition.value().x - PMONITOR->vecPosition.x), PMONITOR->vecSize.y - (m_vRealPosition.value().y - PMONITOR->vecPosition.y)}};
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents maxExtents = {{BORDERSIZE + 2, BORDERSIZE + 2}, {BORDERSIZE + 2, BORDERSIZE + 2}};
|
SBoxExtents maxExtents = {{BORDERSIZE + 2, BORDERSIZE + 2}, {BORDERSIZE + 2, BORDERSIZE + 2}};
|
||||||
|
|
||||||
const auto EXTENTS = g_pDecorationPositioner->getWindowDecorationExtents(m_pSelf.lock());
|
const auto EXTENTS = g_pDecorationPositioner->getWindowDecorationExtents(m_pSelf.lock());
|
||||||
|
|
||||||
if (EXTENTS.topLeft.x > maxExtents.topLeft.x)
|
if (EXTENTS.topLeft.x > maxExtents.topLeft.x)
|
||||||
maxExtents.topLeft.x = EXTENTS.topLeft.x;
|
maxExtents.topLeft.x = EXTENTS.topLeft.x;
|
||||||
|
@ -224,7 +224,7 @@ CBox CWindow::getWindowBoxUnified(uint64_t properties) {
|
||||||
return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
|
return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents EXTENTS = {{0, 0}, {0, 0}};
|
SBoxExtents EXTENTS = {{0, 0}, {0, 0}};
|
||||||
if (properties & RESERVED_EXTENTS)
|
if (properties & RESERVED_EXTENTS)
|
||||||
EXTENTS.addExtents(g_pDecorationPositioner->getWindowDecorationReserved(m_pSelf.lock()));
|
EXTENTS.addExtents(g_pDecorationPositioner->getWindowDecorationReserved(m_pSelf.lock()));
|
||||||
if (properties & INPUT_EXTENTS)
|
if (properties & INPUT_EXTENTS)
|
||||||
|
@ -242,7 +242,7 @@ CBox CWindow::getWindowMainSurfaceBox() {
|
||||||
return {m_vRealPosition.value().x, m_vRealPosition.value().y, m_vRealSize.value().x, m_vRealSize.value().y};
|
return {m_vRealPosition.value().x, m_vRealPosition.value().y, m_vRealSize.value().x, m_vRealSize.value().y};
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents CWindow::getFullWindowReservedArea() {
|
SBoxExtents CWindow::getFullWindowReservedArea() {
|
||||||
return g_pDecorationPositioner->getWindowDecorationReserved(m_pSelf.lock());
|
return g_pDecorationPositioner->getWindowDecorationReserved(m_pSelf.lock());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "../config/ConfigDataValues.hpp"
|
#include "../config/ConfigDataValues.hpp"
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include "../helpers/AnimatedVariable.hpp"
|
#include "../helpers/AnimatedVariable.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/signal/Signal.hpp"
|
#include "../helpers/signal/Signal.hpp"
|
||||||
#include "../helpers/TagKeeper.hpp"
|
#include "../helpers/TagKeeper.hpp"
|
||||||
#include "../macros.hpp"
|
#include "../macros.hpp"
|
||||||
|
@ -310,7 +310,7 @@ class CWindow {
|
||||||
bool m_bReadyToDelete = false;
|
bool m_bReadyToDelete = false;
|
||||||
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
|
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
|
||||||
Vector2D m_vOriginalClosedSize; // drawing the closing animations
|
Vector2D m_vOriginalClosedSize; // drawing the closing animations
|
||||||
SWindowDecorationExtents m_eOriginalClosedExtents;
|
SBoxExtents m_eOriginalClosedExtents;
|
||||||
bool m_bAnimatingIn = false;
|
bool m_bAnimatingIn = false;
|
||||||
|
|
||||||
// For pinned (sticky) windows
|
// For pinned (sticky) windows
|
||||||
|
@ -386,75 +386,75 @@ class CWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
CBox getFullWindowBoundingBox();
|
CBox getFullWindowBoundingBox();
|
||||||
SWindowDecorationExtents getFullWindowExtents();
|
SBoxExtents getFullWindowExtents();
|
||||||
CBox getWindowBoxUnified(uint64_t props);
|
CBox getWindowBoxUnified(uint64_t props);
|
||||||
CBox getWindowMainSurfaceBox();
|
CBox getWindowMainSurfaceBox();
|
||||||
CBox getWindowIdealBoundingBoxIgnoreReserved();
|
CBox getWindowIdealBoundingBoxIgnoreReserved();
|
||||||
void addWindowDeco(std::unique_ptr<IHyprWindowDecoration> deco);
|
void addWindowDeco(std::unique_ptr<IHyprWindowDecoration> deco);
|
||||||
void updateWindowDecos();
|
void updateWindowDecos();
|
||||||
void removeWindowDeco(IHyprWindowDecoration* deco);
|
void removeWindowDeco(IHyprWindowDecoration* deco);
|
||||||
void uncacheWindowDecos();
|
void uncacheWindowDecos();
|
||||||
bool checkInputOnDecos(const eInputType, const Vector2D&, std::any = {});
|
bool checkInputOnDecos(const eInputType, const Vector2D&, std::any = {});
|
||||||
pid_t getPID();
|
pid_t getPID();
|
||||||
IHyprWindowDecoration* getDecorationByType(eDecorationType);
|
IHyprWindowDecoration* getDecorationByType(eDecorationType);
|
||||||
void removeDecorationByType(eDecorationType);
|
void removeDecorationByType(eDecorationType);
|
||||||
void updateToplevel();
|
void updateToplevel();
|
||||||
void updateSurfaceScaleTransformDetails(bool force = false);
|
void updateSurfaceScaleTransformDetails(bool force = false);
|
||||||
void moveToWorkspace(PHLWORKSPACE);
|
void moveToWorkspace(PHLWORKSPACE);
|
||||||
PHLWINDOW X11TransientFor();
|
PHLWINDOW X11TransientFor();
|
||||||
void onUnmap();
|
void onUnmap();
|
||||||
void onMap();
|
void onMap();
|
||||||
void setHidden(bool hidden);
|
void setHidden(bool hidden);
|
||||||
bool isHidden();
|
bool isHidden();
|
||||||
void applyDynamicRule(const SWindowRule& r);
|
void applyDynamicRule(const SWindowRule& r);
|
||||||
void updateDynamicRules();
|
void updateDynamicRules();
|
||||||
SWindowDecorationExtents getFullWindowReservedArea();
|
SBoxExtents getFullWindowReservedArea();
|
||||||
Vector2D middle();
|
Vector2D middle();
|
||||||
bool opaque();
|
bool opaque();
|
||||||
float rounding();
|
float rounding();
|
||||||
bool canBeTorn();
|
bool canBeTorn();
|
||||||
bool shouldSendFullscreenState();
|
bool shouldSendFullscreenState();
|
||||||
void setSuspended(bool suspend);
|
void setSuspended(bool suspend);
|
||||||
bool visibleOnMonitor(CMonitor* pMonitor);
|
bool visibleOnMonitor(CMonitor* pMonitor);
|
||||||
int workspaceID();
|
int workspaceID();
|
||||||
bool onSpecialWorkspace();
|
bool onSpecialWorkspace();
|
||||||
void activate(bool force = false);
|
void activate(bool force = false);
|
||||||
int surfacesCount();
|
int surfacesCount();
|
||||||
|
|
||||||
int getRealBorderSize();
|
int getRealBorderSize();
|
||||||
void updateSpecialRenderData();
|
void updateSpecialRenderData();
|
||||||
void updateSpecialRenderData(const struct SWorkspaceRule&);
|
void updateSpecialRenderData(const struct SWorkspaceRule&);
|
||||||
|
|
||||||
void onBorderAngleAnimEnd(void* ptr);
|
void onBorderAngleAnimEnd(void* ptr);
|
||||||
bool isInCurvedCorner(double x, double y);
|
bool isInCurvedCorner(double x, double y);
|
||||||
bool hasPopupAt(const Vector2D& pos);
|
bool hasPopupAt(const Vector2D& pos);
|
||||||
int popupsCount();
|
int popupsCount();
|
||||||
|
|
||||||
void applyGroupRules();
|
void applyGroupRules();
|
||||||
void createGroup();
|
void createGroup();
|
||||||
void destroyGroup();
|
void destroyGroup();
|
||||||
PHLWINDOW getGroupHead();
|
PHLWINDOW getGroupHead();
|
||||||
PHLWINDOW getGroupTail();
|
PHLWINDOW getGroupTail();
|
||||||
PHLWINDOW getGroupCurrent();
|
PHLWINDOW getGroupCurrent();
|
||||||
PHLWINDOW getGroupPrevious();
|
PHLWINDOW getGroupPrevious();
|
||||||
PHLWINDOW getGroupWindowByIndex(int);
|
PHLWINDOW getGroupWindowByIndex(int);
|
||||||
int getGroupSize();
|
int getGroupSize();
|
||||||
bool canBeGroupedInto(PHLWINDOW pWindow);
|
bool canBeGroupedInto(PHLWINDOW pWindow);
|
||||||
void setGroupCurrent(PHLWINDOW pWindow);
|
void setGroupCurrent(PHLWINDOW pWindow);
|
||||||
void insertWindowToGroup(PHLWINDOW pWindow);
|
void insertWindowToGroup(PHLWINDOW pWindow);
|
||||||
void updateGroupOutputs();
|
void updateGroupOutputs();
|
||||||
void switchWithWindowInGroup(PHLWINDOW pWindow);
|
void switchWithWindowInGroup(PHLWINDOW pWindow);
|
||||||
void setAnimationsToMove();
|
void setAnimationsToMove();
|
||||||
void onWorkspaceAnimUpdate();
|
void onWorkspaceAnimUpdate();
|
||||||
void onUpdateState();
|
void onUpdateState();
|
||||||
void onUpdateMeta();
|
void onUpdateMeta();
|
||||||
void onX11Configure(CBox box);
|
void onX11Configure(CBox box);
|
||||||
void onResourceChangeX11();
|
void onResourceChangeX11();
|
||||||
std::string fetchTitle();
|
std::string fetchTitle();
|
||||||
std::string fetchClass();
|
std::string fetchClass();
|
||||||
void warpCursor();
|
void warpCursor();
|
||||||
PHLWINDOW getSwallower();
|
PHLWINDOW getSwallower();
|
||||||
|
|
||||||
// listeners
|
// listeners
|
||||||
void onAck(uint32_t serial);
|
void onAck(uint32_t serial);
|
||||||
|
|
|
@ -104,24 +104,24 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
||||||
if (ANIMSTYLE.starts_with("slidefadevert")) {
|
if (ANIMSTYLE.starts_with("slidefadevert")) {
|
||||||
if (in) {
|
if (in) {
|
||||||
m_fAlpha.setValueAndWarp(0.f);
|
m_fAlpha.setValueAndWarp(0.f);
|
||||||
m_vRenderOffset.setValueAndWarp(Vector2D(0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f)));
|
m_vRenderOffset.setValueAndWarp(Vector2D(0.0, (left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y) * (movePerc / 100.f)));
|
||||||
m_fAlpha = 1.f;
|
m_fAlpha = 1.f;
|
||||||
m_vRenderOffset = Vector2D(0, 0);
|
m_vRenderOffset = Vector2D(0, 0);
|
||||||
} else {
|
} else {
|
||||||
m_fAlpha.setValueAndWarp(1.f);
|
m_fAlpha.setValueAndWarp(1.f);
|
||||||
m_fAlpha = 0.f;
|
m_fAlpha = 0.f;
|
||||||
m_vRenderOffset = Vector2D(0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f));
|
m_vRenderOffset = Vector2D(0.0, (left ? -PMONITOR->vecSize.y : PMONITOR->vecSize.y) * (movePerc / 100.f));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (in) {
|
if (in) {
|
||||||
m_fAlpha.setValueAndWarp(0.f);
|
m_fAlpha.setValueAndWarp(0.f);
|
||||||
m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0));
|
m_vRenderOffset.setValueAndWarp(Vector2D((left ? PMONITOR->vecSize.x : -PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0));
|
||||||
m_fAlpha = 1.f;
|
m_fAlpha = 1.f;
|
||||||
m_vRenderOffset = Vector2D(0, 0);
|
m_vRenderOffset = Vector2D(0, 0);
|
||||||
} else {
|
} else {
|
||||||
m_fAlpha.setValueAndWarp(1.f);
|
m_fAlpha.setValueAndWarp(1.f);
|
||||||
m_fAlpha = 0.f;
|
m_fAlpha = 0.f;
|
||||||
m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0);
|
m_vRenderOffset = Vector2D((left ? -PMONITOR->vecSize.x : PMONITOR->vecSize.x) * (movePerc / 100.f), 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ANIMSTYLE == "fade") {
|
} else if (ANIMSTYLE == "fade") {
|
||||||
|
@ -142,10 +142,10 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
||||||
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
||||||
|
|
||||||
if (in) {
|
if (in) {
|
||||||
m_vRenderOffset.setValueAndWarp(Vector2D(0, left ? YDISTANCE : -YDISTANCE));
|
m_vRenderOffset.setValueAndWarp(Vector2D(0.0, left ? YDISTANCE : -YDISTANCE));
|
||||||
m_vRenderOffset = Vector2D(0, 0);
|
m_vRenderOffset = Vector2D(0, 0);
|
||||||
} else {
|
} else {
|
||||||
m_vRenderOffset = Vector2D(0, left ? -YDISTANCE : YDISTANCE);
|
m_vRenderOffset = Vector2D(0.0, left ? -YDISTANCE : YDISTANCE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// fallback is slide
|
// fallback is slide
|
||||||
|
@ -155,10 +155,10 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
||||||
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
|
||||||
|
|
||||||
if (in) {
|
if (in) {
|
||||||
m_vRenderOffset.setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0));
|
m_vRenderOffset.setValueAndWarp(Vector2D(left ? XDISTANCE : -XDISTANCE, 0.0));
|
||||||
m_vRenderOffset = Vector2D(0, 0);
|
m_vRenderOffset = Vector2D(0, 0);
|
||||||
} else {
|
} else {
|
||||||
m_vRenderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0);
|
m_vRenderOffset = Vector2D(left ? -XDISTANCE : XDISTANCE, 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "IHID.hpp"
|
#include "IHID.hpp"
|
||||||
#include "../helpers/WLListener.hpp"
|
#include "../helpers/WLListener.hpp"
|
||||||
#include "../macros.hpp"
|
#include "../macros.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "IHID.hpp"
|
#include "IHID.hpp"
|
||||||
#include "../helpers/WLListener.hpp"
|
#include "../helpers/WLListener.hpp"
|
||||||
#include "../macros.hpp"
|
#include "../macros.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
struct wlr_pointer;
|
struct wlr_pointer;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "IHID.hpp"
|
#include "IHID.hpp"
|
||||||
#include "../helpers/WLListener.hpp"
|
#include "../helpers/WLListener.hpp"
|
||||||
#include "../macros.hpp"
|
#include "../macros.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
struct wlr_touch;
|
struct wlr_touch;
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include "IHID.hpp"
|
#include "IHID.hpp"
|
||||||
#include "../helpers/WLListener.hpp"
|
#include "../helpers/WLListener.hpp"
|
||||||
#include "../macros.hpp"
|
#include "../macros.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/Box.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
struct wlr_tablet;
|
struct wlr_tablet;
|
||||||
struct wlr_tablet_tool;
|
struct wlr_tablet_tool;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <any>
|
#include <any>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include "Vector2D.hpp"
|
#include "math/Math.hpp"
|
||||||
#include "Color.hpp"
|
#include "Color.hpp"
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include "../debug/Log.hpp"
|
#include "../debug/Log.hpp"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Vector2D.hpp"
|
#include "math/Math.hpp"
|
||||||
|
|
||||||
constexpr int BAKEDPOINTS = 255;
|
constexpr int BAKEDPOINTS = 255;
|
||||||
constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS;
|
constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS;
|
||||||
|
|
|
@ -1,179 +0,0 @@
|
||||||
#include "Box.hpp"
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
wlr_box CBox::wlr() {
|
|
||||||
CBox rounded = roundInternal();
|
|
||||||
m_bWlrBox = wlr_box{(int)rounded.x, (int)rounded.y, (int)rounded.w, (int)rounded.h};
|
|
||||||
return m_bWlrBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_box* CBox::pWlr() {
|
|
||||||
CBox rounded = roundInternal();
|
|
||||||
m_bWlrBox = wlr_box{(int)rounded.x, (int)rounded.y, (int)rounded.w, (int)rounded.h};
|
|
||||||
return &m_bWlrBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::scale(double scale) {
|
|
||||||
x *= scale;
|
|
||||||
y *= scale;
|
|
||||||
w *= scale;
|
|
||||||
h *= scale;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::scale(const Vector2D& scale) {
|
|
||||||
x *= scale.x;
|
|
||||||
y *= scale.y;
|
|
||||||
w *= scale.x;
|
|
||||||
h *= scale.y;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::translate(const Vector2D& vec) {
|
|
||||||
x += vec.x;
|
|
||||||
y += vec.y;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D CBox::middle() const {
|
|
||||||
return Vector2D{x + w / 2.0, y + h / 2.0};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CBox::containsPoint(const Vector2D& vec) const {
|
|
||||||
return VECINRECT(vec, x, y, x + w, y + h);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CBox::empty() const {
|
|
||||||
return w == 0 || h == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::applyFromWlr() {
|
|
||||||
x = m_bWlrBox.x;
|
|
||||||
y = m_bWlrBox.y;
|
|
||||||
w = m_bWlrBox.width;
|
|
||||||
h = m_bWlrBox.height;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::round() {
|
|
||||||
float newW = x + w - std::round(x);
|
|
||||||
float newH = y + h - std::round(y);
|
|
||||||
x = std::round(x);
|
|
||||||
y = std::round(y);
|
|
||||||
w = std::round(newW);
|
|
||||||
h = std::round(newH);
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::transform(const wl_output_transform t, double w, double h) {
|
|
||||||
wlr_box_transform(&m_bWlrBox, pWlr(), t, w, h);
|
|
||||||
applyFromWlr();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::addExtents(const SWindowDecorationExtents& e) {
|
|
||||||
x -= e.topLeft.x;
|
|
||||||
y -= e.topLeft.y;
|
|
||||||
w += e.topLeft.x + e.bottomRight.x;
|
|
||||||
h += e.topLeft.y + e.bottomRight.y;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::scaleFromCenter(double scale) {
|
|
||||||
double oldW = w, oldH = h;
|
|
||||||
|
|
||||||
w *= scale;
|
|
||||||
h *= scale;
|
|
||||||
|
|
||||||
x -= (w - oldW) / 2.0;
|
|
||||||
y -= (h - oldH) / 2.0;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::expand(const double& value) {
|
|
||||||
x -= value;
|
|
||||||
y -= value;
|
|
||||||
w += value * 2.0;
|
|
||||||
h += value * 2.0;
|
|
||||||
|
|
||||||
if (w <= 0 || h <= 0) {
|
|
||||||
w = 0;
|
|
||||||
h = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox& CBox::noNegativeSize() {
|
|
||||||
w = std::clamp(w, 0.0, std::numeric_limits<double>::infinity());
|
|
||||||
h = std::clamp(h, 0.0, std::numeric_limits<double>::infinity());
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox CBox::intersection(const CBox& other) const {
|
|
||||||
const float newX = std::max(x, other.x);
|
|
||||||
const float newY = std::max(y, other.y);
|
|
||||||
const float newBottom = std::min(y + h, other.y + other.h);
|
|
||||||
const float newRight = std::min(x + w, other.x + other.w);
|
|
||||||
float newW = newRight - newX;
|
|
||||||
float newH = newBottom - newY;
|
|
||||||
|
|
||||||
if (newW <= 0 || newH <= 0) {
|
|
||||||
newW = 0;
|
|
||||||
newH = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {newX, newY, newW, newH};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CBox::overlaps(const CBox& other) const {
|
|
||||||
return (other.x + other.w >= x) && (x + w >= other.x) && (other.y + other.h >= y) && (y + h >= other.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CBox::inside(const CBox& bound) const {
|
|
||||||
return bound.x < x && bound.y < y && x + w < bound.x + bound.w && y + h < bound.y + bound.h;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox CBox::roundInternal() {
|
|
||||||
float newW = x + w - std::floor(x);
|
|
||||||
float newH = y + h - std::floor(y);
|
|
||||||
|
|
||||||
return CBox{std::floor(x), std::floor(y), std::floor(newW), std::floor(newH)};
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox CBox::copy() const {
|
|
||||||
return CBox{*this};
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D CBox::pos() const {
|
|
||||||
return {x, y};
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D CBox::size() const {
|
|
||||||
return {w, h};
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D CBox::closestPoint(const Vector2D& vec) const {
|
|
||||||
if (containsPoint(vec))
|
|
||||||
return vec;
|
|
||||||
|
|
||||||
Vector2D nv = vec;
|
|
||||||
nv.x = std::clamp(nv.x, x, x + w);
|
|
||||||
nv.y = std::clamp(nv.y, y, y + h);
|
|
||||||
return nv;
|
|
||||||
}
|
|
||||||
|
|
||||||
SWindowDecorationExtents CBox::extentsFrom(const CBox& small) {
|
|
||||||
return {{small.x - x, small.y - y}, {w - small.w - (small.x - x), h - small.h - (small.y - y)}};
|
|
||||||
}
|
|
|
@ -1,92 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "Vector2D.hpp"
|
|
||||||
#include "../SharedDefs.hpp"
|
|
||||||
#include "../includes.hpp"
|
|
||||||
|
|
||||||
class CBox {
|
|
||||||
public:
|
|
||||||
CBox(double x_, double y_, double w_, double h_) {
|
|
||||||
x = x_;
|
|
||||||
y = y_;
|
|
||||||
w = w_;
|
|
||||||
h = h_;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox() {
|
|
||||||
w = 0;
|
|
||||||
h = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox(const wlr_box& box) {
|
|
||||||
x = box.x;
|
|
||||||
y = box.y;
|
|
||||||
w = box.width;
|
|
||||||
h = box.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox(const double d) {
|
|
||||||
x = d;
|
|
||||||
y = d;
|
|
||||||
w = d;
|
|
||||||
h = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox(const Vector2D& pos, const Vector2D& size) {
|
|
||||||
x = pos.x;
|
|
||||||
y = pos.y;
|
|
||||||
w = size.x;
|
|
||||||
h = size.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_box wlr();
|
|
||||||
wlr_box* pWlr();
|
|
||||||
|
|
||||||
CBox& applyFromWlr();
|
|
||||||
CBox& scale(double scale);
|
|
||||||
CBox& scaleFromCenter(double scale);
|
|
||||||
CBox& scale(const Vector2D& scale);
|
|
||||||
CBox& translate(const Vector2D& vec);
|
|
||||||
CBox& round();
|
|
||||||
CBox& transform(const wl_output_transform t, double w, double h);
|
|
||||||
CBox& addExtents(const SWindowDecorationExtents& e);
|
|
||||||
CBox& expand(const double& value);
|
|
||||||
CBox& noNegativeSize();
|
|
||||||
|
|
||||||
CBox copy() const;
|
|
||||||
CBox intersection(const CBox& other) const;
|
|
||||||
bool overlaps(const CBox& other) const;
|
|
||||||
bool inside(const CBox& bound) const;
|
|
||||||
|
|
||||||
SWindowDecorationExtents extentsFrom(const CBox&); // this is the big box
|
|
||||||
|
|
||||||
Vector2D middle() const;
|
|
||||||
Vector2D pos() const;
|
|
||||||
Vector2D size() const;
|
|
||||||
Vector2D closestPoint(const Vector2D& vec) const;
|
|
||||||
|
|
||||||
bool containsPoint(const Vector2D& vec) const;
|
|
||||||
bool empty() const;
|
|
||||||
|
|
||||||
double x = 0, y = 0;
|
|
||||||
union {
|
|
||||||
double w;
|
|
||||||
double width;
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
double h;
|
|
||||||
double height;
|
|
||||||
};
|
|
||||||
|
|
||||||
double rot = 0; /* rad, ccw */
|
|
||||||
|
|
||||||
//
|
|
||||||
bool operator==(const CBox& rhs) const {
|
|
||||||
return x == rhs.x && y == rhs.y && w == rhs.w && h == rhs.h;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
CBox roundInternal();
|
|
||||||
|
|
||||||
wlr_box m_bWlrBox;
|
|
||||||
};
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "Vector2D.hpp"
|
#include "math/Math.hpp"
|
||||||
|
|
||||||
typedef uint32_t DRMFormat;
|
typedef uint32_t DRMFormat;
|
||||||
typedef uint32_t SHMFormat;
|
typedef uint32_t SHMFormat;
|
||||||
|
|
|
@ -762,7 +762,7 @@ Vector2D configStringToVector2D(const std::string& VALUE) {
|
||||||
if (std::getline(iss, token))
|
if (std::getline(iss, token))
|
||||||
throw std::invalid_argument("Invalid string format");
|
throw std::invalid_argument("Invalid string format");
|
||||||
|
|
||||||
return Vector2D(x, y);
|
return Vector2D((double)x, (double)y);
|
||||||
}
|
}
|
||||||
|
|
||||||
double normalizeAngleRad(double ang) {
|
double normalizeAngleRad(double ang) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <wlr/util/box.h>
|
#include <wlr/util/box.h>
|
||||||
#include "Vector2D.hpp"
|
#include "math/Math.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <format>
|
#include <format>
|
||||||
|
|
||||||
|
|
|
@ -358,7 +358,9 @@ void CMonitor::addDamage(const CBox* box) {
|
||||||
g_pCompositor->scheduleFrameForMonitor(this);
|
g_pCompositor->scheduleFrameForMonitor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wlr_damage_ring_add_box(&damage, const_cast<CBox*>(box)->pWlr()))
|
wlr_box damageBox = {(int)box->x, (int)box->y, (int)box->w, (int)box->h};
|
||||||
|
|
||||||
|
if (wlr_damage_ring_add_box(&damage, &damageBox))
|
||||||
g_pCompositor->scheduleFrameForMonitor(this);
|
g_pCompositor->scheduleFrameForMonitor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
#include "Timer.hpp"
|
#include "Timer.hpp"
|
||||||
#include "Region.hpp"
|
#include "math/Math.hpp"
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include "signal/Signal.hpp"
|
#include "signal/Signal.hpp"
|
||||||
|
|
||||||
|
|
|
@ -1,183 +0,0 @@
|
||||||
#include "Region.hpp"
|
|
||||||
extern "C" {
|
|
||||||
#include <wlr/util/box.h>
|
|
||||||
#include <wlr/util/region.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr const int64_t MAX_REGION_SIDE = 10000000;
|
|
||||||
|
|
||||||
CRegion::CRegion() {
|
|
||||||
pixman_region32_init(&m_rRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion::CRegion(const pixman_region32_t* const ref) {
|
|
||||||
pixman_region32_init(&m_rRegion);
|
|
||||||
pixman_region32_copy(&m_rRegion, ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion::CRegion(double x, double y, double w, double h) {
|
|
||||||
pixman_region32_init_rect(&m_rRegion, x, y, w, h);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion::CRegion(wlr_box* box) {
|
|
||||||
pixman_region32_init_rect(&m_rRegion, box->x, box->y, box->width, box->height);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion::CRegion(const CBox& box) {
|
|
||||||
pixman_region32_init_rect(&m_rRegion, box.x, box.y, box.w, box.h);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion::CRegion(pixman_box32_t* box) {
|
|
||||||
pixman_region32_init_rect(&m_rRegion, box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion::CRegion(const CRegion& other) {
|
|
||||||
pixman_region32_init(&m_rRegion);
|
|
||||||
pixman_region32_copy(&m_rRegion, const_cast<CRegion*>(&other)->pixman());
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion::CRegion(CRegion&& other) {
|
|
||||||
pixman_region32_init(&m_rRegion);
|
|
||||||
pixman_region32_copy(&m_rRegion, other.pixman());
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion::~CRegion() {
|
|
||||||
pixman_region32_fini(&m_rRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::clear() {
|
|
||||||
pixman_region32_clear(&m_rRegion);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::set(const CRegion& other) {
|
|
||||||
pixman_region32_copy(&m_rRegion, const_cast<CRegion*>(&other)->pixman());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::add(const CRegion& other) {
|
|
||||||
pixman_region32_union(&m_rRegion, &m_rRegion, const_cast<CRegion*>(&other)->pixman());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::add(double x, double y, double w, double h) {
|
|
||||||
pixman_region32_union_rect(&m_rRegion, &m_rRegion, x, y, w, h);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::add(const CBox& other) {
|
|
||||||
pixman_region32_union_rect(&m_rRegion, &m_rRegion, other.x, other.y, other.w, other.h);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::subtract(const CRegion& other) {
|
|
||||||
pixman_region32_subtract(&m_rRegion, &m_rRegion, const_cast<CRegion*>(&other)->pixman());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::intersect(const CRegion& other) {
|
|
||||||
pixman_region32_intersect(&m_rRegion, &m_rRegion, const_cast<CRegion*>(&other)->pixman());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::intersect(double x, double y, double w, double h) {
|
|
||||||
pixman_region32_intersect_rect(&m_rRegion, &m_rRegion, x, y, w, h);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::invert(pixman_box32_t* box) {
|
|
||||||
pixman_region32_inverse(&m_rRegion, &m_rRegion, box);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::invert(const CBox& box) {
|
|
||||||
pixman_box32 pixmanBox = {box.x, box.y, box.w + box.x, box.h + box.y};
|
|
||||||
return this->invert(&pixmanBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::translate(const Vector2D& vec) {
|
|
||||||
pixman_region32_translate(&m_rRegion, vec.x, vec.y);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::transform(const wl_output_transform t, double w, double h) {
|
|
||||||
wlr_region_transform(&m_rRegion, &m_rRegion, t, w, h);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::rationalize() {
|
|
||||||
intersect(CBox{-MAX_REGION_SIDE, -MAX_REGION_SIDE, MAX_REGION_SIDE * 2, MAX_REGION_SIDE * 2});
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion CRegion::copy() const {
|
|
||||||
return CRegion(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::scale(float scale) {
|
|
||||||
wlr_region_scale(&m_rRegion, &m_rRegion, scale);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& CRegion::scale(const Vector2D& scale) {
|
|
||||||
wlr_region_scale_xy(&m_rRegion, &m_rRegion, scale.x, scale.y);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<pixman_box32_t> CRegion::getRects() const {
|
|
||||||
std::vector<pixman_box32_t> result;
|
|
||||||
|
|
||||||
int rectsNum = 0;
|
|
||||||
const auto RECTSARR = pixman_region32_rectangles(&m_rRegion, &rectsNum);
|
|
||||||
|
|
||||||
result.assign(RECTSARR, RECTSARR + rectsNum);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
CBox CRegion::getExtents() {
|
|
||||||
pixman_box32_t* box = pixman_region32_extents(&m_rRegion);
|
|
||||||
return {box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1};
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CRegion::containsPoint(const Vector2D& vec) const {
|
|
||||||
return pixman_region32_contains_point(&m_rRegion, vec.x, vec.y, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CRegion::empty() const {
|
|
||||||
return !pixman_region32_not_empty(&m_rRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D CRegion::closestPoint(const Vector2D& vec) const {
|
|
||||||
if (containsPoint(vec))
|
|
||||||
return vec;
|
|
||||||
|
|
||||||
double bestDist = __FLT_MAX__;
|
|
||||||
Vector2D leader = vec;
|
|
||||||
|
|
||||||
for (auto& box : getRects()) {
|
|
||||||
double x = 0, y = 0;
|
|
||||||
|
|
||||||
if (vec.x >= box.x2)
|
|
||||||
x = box.x2 - 1;
|
|
||||||
else if (vec.x < box.x1)
|
|
||||||
x = box.x1;
|
|
||||||
else
|
|
||||||
x = vec.x;
|
|
||||||
|
|
||||||
if (vec.y >= box.y2)
|
|
||||||
y = box.y2 - 1;
|
|
||||||
else if (vec.y < box.y1)
|
|
||||||
y = box.y1;
|
|
||||||
else
|
|
||||||
y = vec.y;
|
|
||||||
|
|
||||||
double distance = pow(x, 2) + pow(y, 2);
|
|
||||||
if (distance < bestDist) {
|
|
||||||
bestDist = distance;
|
|
||||||
leader = {x, y};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return leader;
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include <pixman.h>
|
|
||||||
#include <vector>
|
|
||||||
#include "Vector2D.hpp"
|
|
||||||
#include "Box.hpp"
|
|
||||||
|
|
||||||
struct wlr_box;
|
|
||||||
|
|
||||||
class CRegion {
|
|
||||||
public:
|
|
||||||
/* Create an empty region */
|
|
||||||
CRegion();
|
|
||||||
/* Create from a reference. Copies, does not own. */
|
|
||||||
CRegion(const pixman_region32_t* const ref);
|
|
||||||
/* Create from a box */
|
|
||||||
CRegion(double x, double y, double w, double h);
|
|
||||||
/* Create from a wlr_box */
|
|
||||||
CRegion(wlr_box* box);
|
|
||||||
/* Create from a CBox */
|
|
||||||
CRegion(const CBox& box);
|
|
||||||
/* Create from a pixman_box32_t */
|
|
||||||
CRegion(pixman_box32_t* box);
|
|
||||||
|
|
||||||
CRegion(const CRegion&);
|
|
||||||
CRegion(CRegion&&);
|
|
||||||
|
|
||||||
~CRegion();
|
|
||||||
|
|
||||||
CRegion& operator=(CRegion&& other) {
|
|
||||||
pixman_region32_copy(&m_rRegion, other.pixman());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& operator=(CRegion& other) {
|
|
||||||
pixman_region32_copy(&m_rRegion, other.pixman());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion& clear();
|
|
||||||
CRegion& set(const CRegion& other);
|
|
||||||
CRegion& add(const CRegion& other);
|
|
||||||
CRegion& add(double x, double y, double w, double h);
|
|
||||||
CRegion& add(const CBox& other);
|
|
||||||
CRegion& subtract(const CRegion& other);
|
|
||||||
CRegion& intersect(const CRegion& other);
|
|
||||||
CRegion& intersect(double x, double y, double w, double h);
|
|
||||||
CRegion& translate(const Vector2D& vec);
|
|
||||||
CRegion& transform(const wl_output_transform t, double w, double h);
|
|
||||||
CRegion& invert(pixman_box32_t* box);
|
|
||||||
CRegion& invert(const CBox& box);
|
|
||||||
CRegion& scale(float scale);
|
|
||||||
CRegion& scale(const Vector2D& scale);
|
|
||||||
CRegion& rationalize();
|
|
||||||
CBox getExtents();
|
|
||||||
bool containsPoint(const Vector2D& vec) const;
|
|
||||||
bool empty() const;
|
|
||||||
Vector2D closestPoint(const Vector2D& vec) const;
|
|
||||||
CRegion copy() const;
|
|
||||||
|
|
||||||
std::vector<pixman_box32_t> getRects() const;
|
|
||||||
|
|
||||||
//
|
|
||||||
pixman_region32_t* pixman() {
|
|
||||||
return &m_rRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
pixman_region32_t m_rRegion;
|
|
||||||
};
|
|
|
@ -1,58 +0,0 @@
|
||||||
#include "Vector2D.hpp"
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
Vector2D::Vector2D(double xx, double yy) {
|
|
||||||
x = xx;
|
|
||||||
y = yy;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D::Vector2D() {
|
|
||||||
x = 0;
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D::Vector2D(const Hyprlang::VEC2& ref) {
|
|
||||||
x = ref.x;
|
|
||||||
y = ref.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D::~Vector2D() {}
|
|
||||||
|
|
||||||
double Vector2D::normalize() {
|
|
||||||
// get max abs
|
|
||||||
const auto max = std::abs(x) > std::abs(y) ? std::abs(x) : std::abs(y);
|
|
||||||
|
|
||||||
x /= max;
|
|
||||||
y /= max;
|
|
||||||
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D Vector2D::floor() const {
|
|
||||||
return Vector2D(std::floor(x), std::floor(y));
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D Vector2D::round() const {
|
|
||||||
return Vector2D(std::round(x), std::round(y));
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) const {
|
|
||||||
return Vector2D(std::clamp(this->x, min.x, max.x < min.x ? INFINITY : max.x), std::clamp(this->y, min.y, max.y < min.y ? INFINITY : max.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
double Vector2D::distance(const Vector2D& other) const {
|
|
||||||
return std::sqrt(distanceSq(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
double Vector2D::distanceSq(const Vector2D& other) const {
|
|
||||||
return (x - other.x) * (x - other.x) + (y - other.y) * (y - other.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
double Vector2D::size() const {
|
|
||||||
return std::sqrt(x * x + y * y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D Vector2D::getComponentMax(const Vector2D& other) const {
|
|
||||||
return Vector2D(std::max(this->x, other.x), std::max(this->y, other.y));
|
|
||||||
}
|
|
|
@ -1,133 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <format>
|
|
||||||
#include "../macros.hpp"
|
|
||||||
#include <hyprlang.hpp>
|
|
||||||
|
|
||||||
class Vector2D {
|
|
||||||
public:
|
|
||||||
Vector2D(double, double);
|
|
||||||
Vector2D();
|
|
||||||
~Vector2D();
|
|
||||||
Vector2D(const Hyprlang::VEC2&);
|
|
||||||
|
|
||||||
double x = 0;
|
|
||||||
double y = 0;
|
|
||||||
|
|
||||||
// returns the scale
|
|
||||||
double normalize();
|
|
||||||
|
|
||||||
Vector2D operator+(const Vector2D& a) const {
|
|
||||||
return Vector2D(this->x + a.x, this->y + a.y);
|
|
||||||
}
|
|
||||||
Vector2D operator-(const Vector2D& a) const {
|
|
||||||
return Vector2D(this->x - a.x, this->y - a.y);
|
|
||||||
}
|
|
||||||
Vector2D operator-() const {
|
|
||||||
return Vector2D(-this->x, -this->y);
|
|
||||||
}
|
|
||||||
Vector2D operator*(const double& a) const {
|
|
||||||
return Vector2D(this->x * a, this->y * a);
|
|
||||||
}
|
|
||||||
Vector2D operator/(const double& a) const {
|
|
||||||
return Vector2D(this->x / a, this->y / a);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Vector2D& a) const {
|
|
||||||
return a.x == x && a.y == y;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const Vector2D& a) const {
|
|
||||||
return a.x != x || a.y != y;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D operator*(const Vector2D& a) const {
|
|
||||||
return Vector2D(this->x * a.x, this->y * a.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2D operator/(const Vector2D& a) const {
|
|
||||||
return Vector2D(this->x / a.x, this->y / a.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator>(const Vector2D& a) const {
|
|
||||||
return this->x > a.x && this->y > a.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<(const Vector2D& a) const {
|
|
||||||
return this->x < a.x && this->y < a.y;
|
|
||||||
}
|
|
||||||
Vector2D& operator+=(const Vector2D& a) {
|
|
||||||
this->x += a.x;
|
|
||||||
this->y += a.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Vector2D& operator-=(const Vector2D& a) {
|
|
||||||
this->x -= a.x;
|
|
||||||
this->y -= a.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Vector2D& operator*=(const Vector2D& a) {
|
|
||||||
this->x *= a.x;
|
|
||||||
this->y *= a.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Vector2D& operator/=(const Vector2D& a) {
|
|
||||||
this->x /= a.x;
|
|
||||||
this->y /= a.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Vector2D& operator*=(const double& a) {
|
|
||||||
this->x *= a;
|
|
||||||
this->y *= a;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
Vector2D& operator/=(const double& a) {
|
|
||||||
this->x /= a;
|
|
||||||
this->y /= a;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
double distance(const Vector2D& other) const;
|
|
||||||
double distanceSq(const Vector2D& other) const;
|
|
||||||
double size() const;
|
|
||||||
Vector2D clamp(const Vector2D& min, const Vector2D& max = Vector2D{-1, -1}) const;
|
|
||||||
|
|
||||||
Vector2D floor() const;
|
|
||||||
Vector2D round() const;
|
|
||||||
|
|
||||||
Vector2D getComponentMax(const Vector2D& other) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
format specification
|
|
||||||
- 'j', as json array
|
|
||||||
- 'X', same as std::format("{}x{}", vec.x, vec.y)
|
|
||||||
- number, floating point precision, use `0` to format as integer
|
|
||||||
*/
|
|
||||||
template <typename CharT>
|
|
||||||
struct std::formatter<Vector2D, CharT> : std::formatter<CharT> {
|
|
||||||
bool formatJson = false;
|
|
||||||
bool formatX = false;
|
|
||||||
std::string precision = "";
|
|
||||||
FORMAT_PARSE(FORMAT_FLAG('j', formatJson) //
|
|
||||||
FORMAT_FLAG('X', formatX) //
|
|
||||||
FORMAT_NUMBER(precision),
|
|
||||||
Vector2D)
|
|
||||||
|
|
||||||
template <typename FormatContext>
|
|
||||||
auto format(const Vector2D& vec, FormatContext& ctx) const {
|
|
||||||
std::string formatString = precision.empty() ? "{}" : std::format("{{:.{}f}}", precision);
|
|
||||||
|
|
||||||
if (formatJson)
|
|
||||||
formatString = std::format("[{0}, {0}]", formatString);
|
|
||||||
else if (formatX)
|
|
||||||
formatString = std::format("{0}x{0}", formatString);
|
|
||||||
else
|
|
||||||
formatString = std::format("[Vector2D: x: {0}, y: {0}]", formatString);
|
|
||||||
try {
|
|
||||||
string buf = std::vformat(formatString, std::make_format_args(vec.x, vec.y));
|
|
||||||
return std::format_to(ctx.out(), "{}", buf);
|
|
||||||
} catch (std::format_error& e) { return std::format_to(ctx.out(), "[{}, {}]", vec.x, vec.y); }
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "AnimatedVariable.hpp"
|
#include "AnimatedVariable.hpp"
|
||||||
#include "../desktop/WLSurface.hpp"
|
#include "../desktop/WLSurface.hpp"
|
||||||
#include "signal/Signal.hpp"
|
#include "signal/Signal.hpp"
|
||||||
#include "Region.hpp"
|
#include "math/Math.hpp"
|
||||||
|
|
||||||
class CMonitor;
|
class CMonitor;
|
||||||
class IPointer;
|
class IPointer;
|
||||||
|
|
220
src/helpers/math/Math.cpp
Normal file
220
src/helpers/math/Math.cpp
Normal file
|
@ -0,0 +1,220 @@
|
||||||
|
#include "Math.hpp"
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
Hyprutils::Math::eTransform wlTransformToHyprutils(wl_output_transform t) {
|
||||||
|
switch (t) {
|
||||||
|
case WL_OUTPUT_TRANSFORM_NORMAL: return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_NORMAL;
|
||||||
|
case WL_OUTPUT_TRANSFORM_180: return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_180;
|
||||||
|
case WL_OUTPUT_TRANSFORM_90: return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_90;
|
||||||
|
case WL_OUTPUT_TRANSFORM_270: return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_270;
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED: return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_FLIPPED;
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180: return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_FLIPPED_180;
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270: return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_FLIPPED_270;
|
||||||
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90: return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_FLIPPED_90;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return Hyprutils::Math::eTransform::HYPRUTILS_TRANSFORM_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void matrixIdentity(float mat[9]) {
|
||||||
|
static const float identity[9] = {
|
||||||
|
1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
};
|
||||||
|
memcpy(mat, identity, sizeof(identity));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void matrixMultiply(float mat[9], const float a[9], const float b[9]) {
|
||||||
|
float product[9];
|
||||||
|
|
||||||
|
product[0] = a[0] * b[0] + a[1] * b[3] + a[2] * b[6];
|
||||||
|
product[1] = a[0] * b[1] + a[1] * b[4] + a[2] * b[7];
|
||||||
|
product[2] = a[0] * b[2] + a[1] * b[5] + a[2] * b[8];
|
||||||
|
|
||||||
|
product[3] = a[3] * b[0] + a[4] * b[3] + a[5] * b[6];
|
||||||
|
product[4] = a[3] * b[1] + a[4] * b[4] + a[5] * b[7];
|
||||||
|
product[5] = a[3] * b[2] + a[4] * b[5] + a[5] * b[8];
|
||||||
|
|
||||||
|
product[6] = a[6] * b[0] + a[7] * b[3] + a[8] * b[6];
|
||||||
|
product[7] = a[6] * b[1] + a[7] * b[4] + a[8] * b[7];
|
||||||
|
product[8] = a[6] * b[2] + a[7] * b[5] + a[8] * b[8];
|
||||||
|
|
||||||
|
memcpy(mat, product, sizeof(product));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void matrixTranspose(float mat[9], const float a[9]) {
|
||||||
|
float transposition[9] = {
|
||||||
|
a[0], a[3], a[6], a[1], a[4], a[7], a[2], a[5], a[8],
|
||||||
|
};
|
||||||
|
memcpy(mat, transposition, sizeof(transposition));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void matrixTranslate(float mat[9], float x, float y) {
|
||||||
|
float translate[9] = {
|
||||||
|
1.0f, 0.0f, x, 0.0f, 1.0f, y, 0.0f, 0.0f, 1.0f,
|
||||||
|
};
|
||||||
|
wlr_matrix_multiply(mat, mat, translate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void matrixScale(float mat[9], float x, float y) {
|
||||||
|
float scale[9] = {
|
||||||
|
x, 0.0f, 0.0f, 0.0f, y, 0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
};
|
||||||
|
wlr_matrix_multiply(mat, mat, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void matrixRotate(float mat[9], float rad) {
|
||||||
|
float rotate[9] = {
|
||||||
|
cos(rad), -sin(rad), 0.0f, sin(rad), cos(rad), 0.0f, 0.0f, 0.0f, 1.0f,
|
||||||
|
};
|
||||||
|
wlr_matrix_multiply(mat, mat, rotate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::unordered_map<eTransform, std::array<float, 9>> transforms = {
|
||||||
|
{HYPRUTILS_TRANSFORM_NORMAL,
|
||||||
|
{
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
{HYPRUTILS_TRANSFORM_90,
|
||||||
|
{
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
-1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
{HYPRUTILS_TRANSFORM_180,
|
||||||
|
{
|
||||||
|
-1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
-1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
{HYPRUTILS_TRANSFORM_270,
|
||||||
|
{
|
||||||
|
0.0f,
|
||||||
|
-1.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
{HYPRUTILS_TRANSFORM_FLIPPED,
|
||||||
|
{
|
||||||
|
-1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
{HYPRUTILS_TRANSFORM_FLIPPED_90,
|
||||||
|
{
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
{HYPRUTILS_TRANSFORM_FLIPPED_180,
|
||||||
|
{
|
||||||
|
1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
-1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
{HYPRUTILS_TRANSFORM_FLIPPED_270,
|
||||||
|
{
|
||||||
|
0.0f,
|
||||||
|
-1.0f,
|
||||||
|
0.0f,
|
||||||
|
-1.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
0.0f,
|
||||||
|
1.0f,
|
||||||
|
}},
|
||||||
|
};
|
||||||
|
|
||||||
|
static void matrixTransform(float mat[9], eTransform transform) {
|
||||||
|
matrixMultiply(mat, mat, transforms.at(transform).data());
|
||||||
|
}
|
||||||
|
|
||||||
|
static void matrixProjection(float mat[9], int width, int height, eTransform transform) {
|
||||||
|
memset(mat, 0, sizeof(*mat) * 9);
|
||||||
|
|
||||||
|
const float* t = transforms.at(transform).data();
|
||||||
|
float x = 2.0f / width;
|
||||||
|
float y = 2.0f / height;
|
||||||
|
|
||||||
|
// Rotation + reflection
|
||||||
|
mat[0] = x * t[0];
|
||||||
|
mat[1] = x * t[1];
|
||||||
|
mat[3] = y * -t[3];
|
||||||
|
mat[4] = y * -t[4];
|
||||||
|
|
||||||
|
// Translation
|
||||||
|
mat[2] = -copysign(1.0f, mat[0] + mat[1]);
|
||||||
|
mat[5] = -copysign(1.0f, mat[3] + mat[4]);
|
||||||
|
|
||||||
|
// Identity
|
||||||
|
mat[8] = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void projectBox(float mat[9], CBox& box, eTransform transform, float rotation, const float projection[9]) {
|
||||||
|
double x = box.x;
|
||||||
|
double y = box.y;
|
||||||
|
double width = box.width;
|
||||||
|
double height = box.height;
|
||||||
|
|
||||||
|
matrixIdentity(mat);
|
||||||
|
matrixTranslate(mat, x, y);
|
||||||
|
|
||||||
|
if (rotation != 0) {
|
||||||
|
matrixTranslate(mat, width / 2, height / 2);
|
||||||
|
matrixRotate(mat, rotation);
|
||||||
|
matrixTranslate(mat, -width / 2, -height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_matrix_scale(mat, width, height);
|
||||||
|
|
||||||
|
if (transform != HYPRUTILS_TRANSFORM_NORMAL) {
|
||||||
|
matrixTranslate(mat, 0.5, 0.5);
|
||||||
|
matrixTransform(mat, transform);
|
||||||
|
matrixTranslate(mat, -0.5, -0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
matrixMultiply(mat, projection, mat);
|
||||||
|
}
|
11
src/helpers/math/Math.hpp
Normal file
11
src/helpers/math/Math.hpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wayland-server-protocol.h>
|
||||||
|
|
||||||
|
// includes box and vector as well
|
||||||
|
#include <hyprutils/math/Region.hpp>
|
||||||
|
|
||||||
|
using namespace Hyprutils::Math;
|
||||||
|
|
||||||
|
eTransform wlTransformToHyprutils(wl_output_transform t);
|
||||||
|
void projectBox(float mat[9], CBox& box, eTransform transform, float rotation, const float projection[9]);
|
|
@ -110,6 +110,4 @@ extern "C" {
|
||||||
#define XWAYLAND true
|
#define XWAYLAND true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "helpers/Vector2D.hpp"
|
|
||||||
#include "helpers/Box.hpp"
|
|
||||||
#include "SharedDefs.hpp"
|
#include "SharedDefs.hpp"
|
||||||
|
|
|
@ -180,9 +180,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
||||||
auto calcPos = PWINDOW->m_vPosition;
|
auto calcPos = PWINDOW->m_vPosition;
|
||||||
auto calcSize = PWINDOW->m_vSize;
|
auto calcSize = PWINDOW->m_vSize;
|
||||||
|
|
||||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? gapsOut.left : gapsIn.left, DISPLAYTOP ? gapsOut.top : gapsIn.top);
|
const auto OFFSETTOPLEFT = Vector2D((double)(DISPLAYLEFT ? gapsOut.left : gapsIn.left), (double)(DISPLAYTOP ? gapsOut.top : gapsIn.top));
|
||||||
|
|
||||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? gapsOut.right : gapsIn.right, DISPLAYBOTTOM ? gapsOut.bottom : gapsIn.bottom);
|
const auto OFFSETBOTTOMRIGHT = Vector2D((double)(DISPLAYRIGHT ? gapsOut.right : gapsIn.right), (double)(DISPLAYBOTTOM ? gapsOut.bottom : gapsIn.bottom));
|
||||||
|
|
||||||
calcPos = calcPos + OFFSETTOPLEFT;
|
calcPos = calcPos + OFFSETTOPLEFT;
|
||||||
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
||||||
|
@ -912,11 +912,11 @@ void CHyprDwindleLayout::moveWindowTo(PHLWINDOW pWindow, const std::string& dir,
|
||||||
|
|
||||||
switch (dir[0]) {
|
switch (dir[0]) {
|
||||||
case 't':
|
case 't':
|
||||||
case 'u': focalPoint = pWindow->m_vPosition + Vector2D{pWindow->m_vSize.x / 2.f, -1}; break;
|
case 'u': focalPoint = pWindow->m_vPosition + Vector2D{pWindow->m_vSize.x / 2.0, -1.0}; break;
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'b': focalPoint = pWindow->m_vPosition + Vector2D{pWindow->m_vSize.x / 2.f, pWindow->m_vSize.y + 1}; break;
|
case 'b': focalPoint = pWindow->m_vPosition + Vector2D{pWindow->m_vSize.x / 2.0, pWindow->m_vSize.y + 1.0}; break;
|
||||||
case 'l': focalPoint = pWindow->m_vPosition + Vector2D{-1, pWindow->m_vSize.y / 2.f}; break;
|
case 'l': focalPoint = pWindow->m_vPosition + Vector2D{-1.0, pWindow->m_vSize.y / 2.0}; break;
|
||||||
case 'r': focalPoint = pWindow->m_vPosition + Vector2D{pWindow->m_vSize.x + 1, pWindow->m_vSize.y / 2.f}; break;
|
case 'r': focalPoint = pWindow->m_vPosition + Vector2D{pWindow->m_vSize.x + 1.0, pWindow->m_vSize.y / 2.0}; break;
|
||||||
default: UNREACHABLE();
|
default: UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -428,9 +428,9 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||||
if (m_eGrabbedCorner == CORNER_TOPLEFT)
|
if (m_eGrabbedCorner == CORNER_TOPLEFT)
|
||||||
newPos = newPos - newSize + m_vBeginDragSizeXY;
|
newPos = newPos - newSize + m_vBeginDragSizeXY;
|
||||||
else if (m_eGrabbedCorner == CORNER_TOPRIGHT)
|
else if (m_eGrabbedCorner == CORNER_TOPRIGHT)
|
||||||
newPos = newPos + Vector2D(0, (m_vBeginDragSizeXY - newSize).y);
|
newPos = newPos + Vector2D(0.0, (m_vBeginDragSizeXY - newSize).y);
|
||||||
else if (m_eGrabbedCorner == CORNER_BOTTOMLEFT)
|
else if (m_eGrabbedCorner == CORNER_BOTTOMLEFT)
|
||||||
newPos = newPos + Vector2D((m_vBeginDragSizeXY - newSize).x, 0);
|
newPos = newPos + Vector2D((m_vBeginDragSizeXY - newSize).x, 0.0);
|
||||||
|
|
||||||
CBox wb = {newPos, newSize};
|
CBox wb = {newPos, newSize};
|
||||||
wb.round();
|
wb.round();
|
||||||
|
|
|
@ -689,9 +689,9 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||||
auto calcPos = PWINDOW->m_vPosition;
|
auto calcPos = PWINDOW->m_vPosition;
|
||||||
auto calcSize = PWINDOW->m_vSize;
|
auto calcSize = PWINDOW->m_vSize;
|
||||||
|
|
||||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? gapsOut.left : gapsIn.left, DISPLAYTOP ? gapsOut.top : gapsIn.top);
|
const auto OFFSETTOPLEFT = Vector2D((double)(DISPLAYLEFT ? gapsOut.left : gapsIn.left), (double)(DISPLAYTOP ? gapsOut.top : gapsIn.top));
|
||||||
|
|
||||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? gapsOut.right : gapsIn.right, DISPLAYBOTTOM ? gapsOut.bottom : gapsIn.bottom);
|
const auto OFFSETBOTTOMRIGHT = Vector2D((double)(DISPLAYRIGHT ? gapsOut.right : gapsIn.right), (double)(DISPLAYBOTTOM ? gapsOut.bottom : gapsIn.bottom));
|
||||||
|
|
||||||
calcPos = calcPos + OFFSETTOPLEFT;
|
calcPos = calcPos + OFFSETTOPLEFT;
|
||||||
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
||||||
|
|
|
@ -98,3 +98,10 @@
|
||||||
([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })(), err); \
|
([]() constexpr -> std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })(), err); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define HYPRUTILS_FORWARD(ns, name) \
|
||||||
|
namespace Hyprutils { \
|
||||||
|
namespace ns { \
|
||||||
|
class name; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ int wlTick(SP<CEventLoopTimer> self, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimationManager::CAnimationManager() {
|
CAnimationManager::CAnimationManager() {
|
||||||
std::vector<Vector2D> points = {Vector2D(0, 0.75f), Vector2D(0.15f, 1.f)};
|
std::vector<Vector2D> points = {Vector2D(0.0, 0.75), Vector2D(0.15, 1.0)};
|
||||||
m_mBezierCurves["default"].setup(&points);
|
m_mBezierCurves["default"].setup(&points);
|
||||||
|
|
||||||
m_pAnimationTimer = SP<CEventLoopTimer>(new CEventLoopTimer(std::chrono::microseconds(500), wlTick, nullptr));
|
m_pAnimationTimer = SP<CEventLoopTimer>(new CEventLoopTimer(std::chrono::microseconds(500), wlTick, nullptr));
|
||||||
|
@ -36,7 +36,7 @@ void CAnimationManager::removeAllBeziers() {
|
||||||
m_mBezierCurves.clear();
|
m_mBezierCurves.clear();
|
||||||
|
|
||||||
// add the default one
|
// add the default one
|
||||||
std::vector<Vector2D> points = {Vector2D(0, 0.75f), Vector2D(0.15f, 1.f)};
|
std::vector<Vector2D> points = {Vector2D(0.0, 0.75), Vector2D(0.15, 1.0)};
|
||||||
m_mBezierCurves["default"].setup(&points);
|
m_mBezierCurves["default"].setup(&points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,9 +336,9 @@ void CAnimationManager::animationSlide(PHLWINDOW pWindow, std::string force, boo
|
||||||
if (force == "bottom")
|
if (force == "bottom")
|
||||||
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
||||||
else if (force == "left")
|
else if (force == "left")
|
||||||
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0);
|
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0.0);
|
||||||
else if (force == "right")
|
else if (force == "right")
|
||||||
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0);
|
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0.0);
|
||||||
else
|
else
|
||||||
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y);
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y);
|
||||||
|
|
||||||
|
@ -360,16 +360,16 @@ void CAnimationManager::animationSlide(PHLWINDOW pWindow, std::string force, boo
|
||||||
|
|
||||||
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
||||||
if (DISPLAYLEFT && DISPLAYRIGHT) {
|
if (DISPLAYLEFT && DISPLAYRIGHT) {
|
||||||
posOffset = GOALPOS + Vector2D(0, GOALSIZE.y);
|
posOffset = GOALPOS + Vector2D(0.0, GOALSIZE.y);
|
||||||
} else if (DISPLAYLEFT) {
|
} else if (DISPLAYLEFT) {
|
||||||
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0);
|
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0.0);
|
||||||
} else {
|
} else {
|
||||||
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0);
|
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0.0);
|
||||||
}
|
}
|
||||||
} else if (DISPLAYTOP) {
|
} else if (DISPLAYTOP) {
|
||||||
posOffset = GOALPOS - Vector2D(0, GOALSIZE.y);
|
posOffset = GOALPOS - Vector2D(0.0, GOALSIZE.y);
|
||||||
} else if (DISPLAYBOTTOM) {
|
} else if (DISPLAYBOTTOM) {
|
||||||
posOffset = GOALPOS + Vector2D(0, GOALSIZE.y);
|
posOffset = GOALPOS + Vector2D(0.0, GOALSIZE.y);
|
||||||
} else {
|
} else {
|
||||||
if (MIDPOINT.y > PMONITOR->vecPosition.y + PMONITOR->vecSize.y / 2.f)
|
if (MIDPOINT.y > PMONITOR->vecPosition.y + PMONITOR->vecSize.y / 2.f)
|
||||||
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
||||||
|
|
|
@ -149,9 +149,10 @@ void CCursorManager::setXCursor(const std::string& name) {
|
||||||
|
|
||||||
auto image = xcursor->images[0];
|
auto image = xcursor->images[0];
|
||||||
|
|
||||||
m_vCursorBuffers.emplace_back(std::make_unique<CCursorBuffer>(image->buffer, Vector2D{image->width, image->height}, Vector2D{image->hotspot_x, image->hotspot_y}));
|
m_vCursorBuffers.emplace_back(
|
||||||
|
std::make_unique<CCursorBuffer>(image->buffer, Vector2D{(int)image->width, (int)image->height}, Vector2D{(double)image->hotspot_x, (double)image->hotspot_y}));
|
||||||
|
|
||||||
g_pPointerManager->setCursorBuffer(getCursorBuffer(), Vector2D{image->hotspot_x, image->hotspot_y} / scale, scale);
|
g_pPointerManager->setCursorBuffer(getCursorBuffer(), Vector2D{(double)image->hotspot_x, (double)image->hotspot_y} / scale, scale);
|
||||||
if (m_vCursorBuffers.size() > 1)
|
if (m_vCursorBuffers.size() > 1)
|
||||||
wlr_buffer_drop(&m_vCursorBuffers.front()->wlrBuffer.base);
|
wlr_buffer_drop(&m_vCursorBuffers.front()->wlrBuffer.base);
|
||||||
|
|
||||||
|
@ -256,8 +257,8 @@ void CCursorManager::setXWaylandCursor() {
|
||||||
g_pXWayland->setCursor(cairo_image_surface_get_data(CURSOR.surface), cairo_image_surface_get_stride(CURSOR.surface), {CURSOR.size, CURSOR.size},
|
g_pXWayland->setCursor(cairo_image_surface_get_data(CURSOR.surface), cairo_image_surface_get_stride(CURSOR.surface), {CURSOR.size, CURSOR.size},
|
||||||
{CURSOR.hotspotX, CURSOR.hotspotY});
|
{CURSOR.hotspotX, CURSOR.hotspotY});
|
||||||
} else if (const auto XCURSOR = wlr_xcursor_manager_get_xcursor(m_pWLRXCursorMgr, "left_ptr", 1); XCURSOR) {
|
} else if (const auto XCURSOR = wlr_xcursor_manager_get_xcursor(m_pWLRXCursorMgr, "left_ptr", 1); XCURSOR) {
|
||||||
g_pXWayland->setCursor(XCURSOR->images[0]->buffer, XCURSOR->images[0]->width * 4, {XCURSOR->images[0]->width, XCURSOR->images[0]->height},
|
g_pXWayland->setCursor(XCURSOR->images[0]->buffer, XCURSOR->images[0]->width * 4, {(int)XCURSOR->images[0]->width, (int)XCURSOR->images[0]->height},
|
||||||
{XCURSOR->images[0]->hotspot_x, XCURSOR->images[0]->hotspot_y});
|
{(double)XCURSOR->images[0]->hotspot_x, (double)XCURSOR->images[0]->hotspot_y});
|
||||||
} else
|
} else
|
||||||
Debug::log(ERR, "CursorManager: no valid cursor for xwayland");
|
Debug::log(ERR, "CursorManager: no valid cursor for xwayland");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <hyprcursor/hyprcursor.hpp>
|
#include <hyprcursor/hyprcursor.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "../includes.hpp"
|
#include "../includes.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
struct wlr_buffer;
|
struct wlr_buffer;
|
||||||
struct wlr_xcursor_manager;
|
struct wlr_xcursor_manager;
|
||||||
|
|
|
@ -577,7 +577,7 @@ Vector2D CPointerManager::transformedHotspot(SP<CMonitor> pMonitor) {
|
||||||
return {}; // doesn't matter, we have no hw cursor, and this is only for hw cursors
|
return {}; // doesn't matter, we have no hw cursor, and this is only for hw cursors
|
||||||
|
|
||||||
return CBox{currentCursorImage.hotspot * pMonitor->scale, {0, 0}}
|
return CBox{currentCursorImage.hotspot * pMonitor->scale, {0, 0}}
|
||||||
.transform(wlr_output_transform_invert(pMonitor->transform), pMonitor->output->cursor_swapchain->width, pMonitor->output->cursor_swapchain->height)
|
.transform(wlTransformToHyprutils(wlr_output_transform_invert(pMonitor->transform)), pMonitor->output->cursor_swapchain->width, pMonitor->output->cursor_swapchain->height)
|
||||||
.pos();
|
.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
#include "../devices/IPointer.hpp"
|
#include "../devices/IPointer.hpp"
|
||||||
#include "../devices/ITouch.hpp"
|
#include "../devices/ITouch.hpp"
|
||||||
#include "../devices/Tablet.hpp"
|
#include "../devices/Tablet.hpp"
|
||||||
#include "../helpers/Box.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/Region.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../desktop/WLSurface.hpp"
|
#include "../desktop/WLSurface.hpp"
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "../helpers/WLListener.hpp"
|
#include "../helpers/WLListener.hpp"
|
||||||
#include "../macros.hpp"
|
#include "../macros.hpp"
|
||||||
#include "../helpers/signal/Signal.hpp"
|
#include "../helpers/signal/Signal.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../protocols/types/DataDevice.hpp"
|
#include "../protocols/types/DataDevice.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "../../helpers/WLListener.hpp"
|
#include "../../helpers/WLListener.hpp"
|
||||||
#include "../../desktop/WLSurface.hpp"
|
#include "../../desktop/WLSurface.hpp"
|
||||||
#include "../../macros.hpp"
|
#include "../../macros.hpp"
|
||||||
#include "../../helpers/Box.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
#include "../../helpers/signal/Signal.hpp"
|
#include "../../helpers/signal/Signal.hpp"
|
||||||
|
|
||||||
class CInputMethodPopupV2;
|
class CInputMethodPopupV2;
|
||||||
|
|
|
@ -109,16 +109,16 @@ void CInputManager::endWorkspaceSwipe() {
|
||||||
|
|
||||||
if (PWORKSPACEL) {
|
if (PWORKSPACEL) {
|
||||||
if (VERTANIMS)
|
if (VERTANIMS)
|
||||||
PWORKSPACEL->m_vRenderOffset = Vector2D{0, -YDISTANCE};
|
PWORKSPACEL->m_vRenderOffset = Vector2D{0.0, -YDISTANCE};
|
||||||
else
|
else
|
||||||
PWORKSPACEL->m_vRenderOffset = Vector2D{-XDISTANCE, 0};
|
PWORKSPACEL->m_vRenderOffset = Vector2D{-XDISTANCE, 0.0};
|
||||||
}
|
}
|
||||||
} else if (PWORKSPACER) {
|
} else if (PWORKSPACER) {
|
||||||
// to right
|
// to right
|
||||||
if (VERTANIMS)
|
if (VERTANIMS)
|
||||||
PWORKSPACER->m_vRenderOffset = Vector2D{0, YDISTANCE};
|
PWORKSPACER->m_vRenderOffset = Vector2D{0.0, YDISTANCE};
|
||||||
else
|
else
|
||||||
PWORKSPACER->m_vRenderOffset = Vector2D{XDISTANCE, 0};
|
PWORKSPACER->m_vRenderOffset = Vector2D{XDISTANCE, 0.0};
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D();
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D();
|
||||||
|
@ -141,9 +141,9 @@ void CInputManager::endWorkspaceSwipe() {
|
||||||
|
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
|
||||||
if (VERTANIMS)
|
if (VERTANIMS)
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(0, YDISTANCE);
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(0.0, YDISTANCE);
|
||||||
else
|
else
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(XDISTANCE, 0);
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(XDISTANCE, 0.0);
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(1.f);
|
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(1.f);
|
||||||
|
|
||||||
g_pInputManager->unconstrainMouse();
|
g_pInputManager->unconstrainMouse();
|
||||||
|
@ -167,9 +167,9 @@ void CInputManager::endWorkspaceSwipe() {
|
||||||
|
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE);
|
||||||
if (VERTANIMS)
|
if (VERTANIMS)
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(0, -YDISTANCE);
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(0.0, -YDISTANCE);
|
||||||
else
|
else
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(-XDISTANCE, 0);
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(-XDISTANCE, 0.0);
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(1.f);
|
m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(1.f);
|
||||||
|
|
||||||
g_pInputManager->unconstrainMouse();
|
g_pInputManager->unconstrainMouse();
|
||||||
|
@ -269,9 +269,9 @@ void CInputManager::updateWorkspaceSwipe(double delta) {
|
||||||
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
|
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
|
||||||
|
|
||||||
if (VERTANIMS)
|
if (VERTANIMS)
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
|
||||||
else
|
else
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0));
|
||||||
|
|
||||||
g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID);
|
g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID);
|
||||||
return;
|
return;
|
||||||
|
@ -293,11 +293,11 @@ void CInputManager::updateWorkspaceSwipe(double delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VERTANIMS) {
|
if (VERTANIMS) {
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE - YDISTANCE));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE - YDISTANCE));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
|
||||||
} else {
|
} else {
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE - XDISTANCE, 0));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE - XDISTANCE, 0.0));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pCompositor->updateWorkspaceWindowDecos(workspaceIDLeft);
|
g_pCompositor->updateWorkspaceWindowDecos(workspaceIDLeft);
|
||||||
|
@ -309,9 +309,9 @@ void CInputManager::updateWorkspaceSwipe(double delta) {
|
||||||
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
|
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor);
|
||||||
|
|
||||||
if (VERTANIMS)
|
if (VERTANIMS)
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
|
||||||
else
|
else
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0));
|
||||||
|
|
||||||
g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID);
|
g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID);
|
||||||
return;
|
return;
|
||||||
|
@ -333,11 +333,11 @@ void CInputManager::updateWorkspaceSwipe(double delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VERTANIMS) {
|
if (VERTANIMS) {
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE + YDISTANCE));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE + YDISTANCE));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
|
||||||
} else {
|
} else {
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE + XDISTANCE, 0));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE + XDISTANCE, 0.0));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pCompositor->updateWorkspaceWindowDecos(workspaceIDRight);
|
g_pCompositor->updateWorkspaceWindowDecos(workspaceIDRight);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "../../helpers/WLListener.hpp"
|
#include "../../helpers/WLListener.hpp"
|
||||||
#include "../../macros.hpp"
|
#include "../../macros.hpp"
|
||||||
#include "../../helpers/Box.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
#include "../../helpers/signal/Signal.hpp"
|
#include "../../helpers/signal/Signal.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
|
||||||
|
|
||||||
resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) {
|
resource->setSetSize([this](CZwlrLayerSurfaceV1* r, uint32_t x, uint32_t y) {
|
||||||
pending.committed |= STATE_SIZE;
|
pending.committed |= STATE_SIZE;
|
||||||
pending.desiredSize = {x, y};
|
pending.desiredSize = {(int)x, (int)y};
|
||||||
});
|
});
|
||||||
|
|
||||||
resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) {
|
resource->setSetAnchor([this](CZwlrLayerSurfaceV1* r, zwlrLayerSurfaceV1Anchor anchor) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
#include "wlr-layer-shell-unstable-v1.hpp"
|
#include "wlr-layer-shell-unstable-v1.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/signal/Signal.hpp"
|
#include "../helpers/signal/Signal.hpp"
|
||||||
#include "types/SurfaceRole.hpp"
|
#include "types/SurfaceRole.hpp"
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
#include "pointer-constraints-unstable-v1.hpp"
|
#include "pointer-constraints-unstable-v1.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/Region.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/signal/Signal.hpp"
|
#include "../helpers/signal/Signal.hpp"
|
||||||
|
|
||||||
class CWLSurface;
|
class CWLSurface;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
#include "pointer-gestures-unstable-v1.hpp"
|
#include "pointer-gestures-unstable-v1.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
class CPointerGestureSwipe {
|
class CPointerGestureSwipe {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
#include "relative-pointer-unstable-v1.hpp"
|
#include "relative-pointer-unstable-v1.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
class CRelativePointer {
|
class CRelativePointer {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -279,7 +279,7 @@ void CScreencopyProtocolManager::captureOutput(wl_client* client, wl_resource* r
|
||||||
}
|
}
|
||||||
int ow, oh;
|
int ow, oh;
|
||||||
wlr_output_effective_resolution(PFRAME->pMonitor->output, &ow, &oh);
|
wlr_output_effective_resolution(PFRAME->pMonitor->output, &ow, &oh);
|
||||||
PFRAME->box.transform(PFRAME->pMonitor->transform, ow, oh).scale(PFRAME->pMonitor->scale).round();
|
PFRAME->box.transform(wlTransformToHyprutils(PFRAME->pMonitor->transform), ow, oh).scale(PFRAME->pMonitor->scale).round();
|
||||||
|
|
||||||
PFRAME->shmStride = FormatUtils::minStride(PSHMINFO, PFRAME->box.w);
|
PFRAME->shmStride = FormatUtils::minStride(PSHMINFO, PFRAME->box.w);
|
||||||
|
|
||||||
|
@ -556,9 +556,10 @@ bool CScreencopyProtocolManager::copyFrameDmabuf(SScreencopyFrame* frame) {
|
||||||
if (!g_pHyprRenderer->beginRender(frame->pMonitor, fakeDamage, RENDER_MODE_TO_BUFFER, frame->buffer.lock(), nullptr, true))
|
if (!g_pHyprRenderer->beginRender(frame->pMonitor, fakeDamage, RENDER_MODE_TO_BUFFER, frame->buffer.lock(), nullptr, true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CBox monbox = CBox{0, 0, frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y}
|
CBox monbox =
|
||||||
.translate({-frame->box.x, -frame->box.y}) // vvvv kinda ass-backwards but that's how I designed the renderer... sigh.
|
CBox{0, 0, frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y}
|
||||||
.transform(wlr_output_transform_invert(frame->pMonitor->output->transform), frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y);
|
.translate({-frame->box.x, -frame->box.y}) // vvvv kinda ass-backwards but that's how I designed the renderer... sigh.
|
||||||
|
.transform(wlTransformToHyprutils(wlr_output_transform_invert(frame->pMonitor->output->transform)), frame->pMonitor->vecPixelSize.x, frame->pMonitor->vecPixelSize.y);
|
||||||
g_pHyprOpenGL->setMonitorTransformEnabled(true);
|
g_pHyprOpenGL->setMonitorTransformEnabled(true);
|
||||||
g_pHyprOpenGL->setRenderModifEnabled(false);
|
g_pHyprOpenGL->setRenderModifEnabled(false);
|
||||||
g_pHyprOpenGL->renderTexture(TEXTURE, &monbox, 1);
|
g_pHyprOpenGL->renderTexture(TEXTURE, &monbox, 1);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
#include "tablet-v2.hpp"
|
#include "tablet-v2.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
class CTablet;
|
class CTablet;
|
||||||
class CTabletTool;
|
class CTabletTool;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
#include "text-input-unstable-v3.hpp"
|
#include "text-input-unstable-v3.hpp"
|
||||||
#include "../helpers/signal/Signal.hpp"
|
#include "../helpers/signal/Signal.hpp"
|
||||||
#include "../helpers/Box.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
class CWLSurfaceResource;
|
class CWLSurfaceResource;
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ void CToplevelExportProtocolManager::captureToplevel(wl_client* client, wl_resou
|
||||||
PFRAME->box = {0, 0, (int)(pWindow->m_vRealSize.value().x * PMONITOR->scale), (int)(pWindow->m_vRealSize.value().y * PMONITOR->scale)};
|
PFRAME->box = {0, 0, (int)(pWindow->m_vRealSize.value().x * PMONITOR->scale), (int)(pWindow->m_vRealSize.value().y * PMONITOR->scale)};
|
||||||
int ow, oh;
|
int ow, oh;
|
||||||
wlr_output_effective_resolution(PMONITOR->output, &ow, &oh);
|
wlr_output_effective_resolution(PMONITOR->output, &ow, &oh);
|
||||||
PFRAME->box.transform(PMONITOR->transform, ow, oh).round();
|
PFRAME->box.transform(wlTransformToHyprutils(PMONITOR->transform), ow, oh).round();
|
||||||
|
|
||||||
PFRAME->shmStride = FormatUtils::minStride(PSHMINFO, PFRAME->box.w);
|
PFRAME->shmStride = FormatUtils::minStride(PSHMINFO, PFRAME->box.w);
|
||||||
|
|
||||||
|
|
|
@ -514,13 +514,13 @@ CXDGPositionerRules::CXDGPositionerRules(SP<CXDGPositionerResource> positioner)
|
||||||
|
|
||||||
static Vector2D pointForAnchor(const CBox& box, const Vector2D& predictionSize, xdgPositionerAnchor anchor) {
|
static Vector2D pointForAnchor(const CBox& box, const Vector2D& predictionSize, xdgPositionerAnchor anchor) {
|
||||||
switch (anchor) {
|
switch (anchor) {
|
||||||
case XDG_POSITIONER_ANCHOR_TOP: return box.pos() + Vector2D{box.size().x / 2.F - predictionSize.x / 2.F, 0};
|
case XDG_POSITIONER_ANCHOR_TOP: return box.pos() + Vector2D{box.size().x / 2.0 - predictionSize.x / 2.0, 0.0};
|
||||||
case XDG_POSITIONER_ANCHOR_BOTTOM: return box.pos() + Vector2D{box.size().x / 2.F - predictionSize.x / 2.F, box.size().y};
|
case XDG_POSITIONER_ANCHOR_BOTTOM: return box.pos() + Vector2D{box.size().x / 2.0 - predictionSize.x / 2.0, box.size().y};
|
||||||
case XDG_POSITIONER_ANCHOR_LEFT: return box.pos() + Vector2D{0, box.size().y / 2.F - predictionSize.y / 2.F};
|
case XDG_POSITIONER_ANCHOR_LEFT: return box.pos() + Vector2D{0.0, box.size().y / 2.0 - predictionSize.y / 2.0};
|
||||||
case XDG_POSITIONER_ANCHOR_RIGHT: return box.pos() + Vector2D{box.size().x, box.size().y / 2.F - predictionSize.y / 2.F};
|
case XDG_POSITIONER_ANCHOR_RIGHT: return box.pos() + Vector2D{box.size().x, box.size().y / 2.F - predictionSize.y / 2.0};
|
||||||
case XDG_POSITIONER_ANCHOR_TOP_LEFT: return box.pos();
|
case XDG_POSITIONER_ANCHOR_TOP_LEFT: return box.pos();
|
||||||
case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT: return box.pos() + Vector2D{0, box.size().y};
|
case XDG_POSITIONER_ANCHOR_BOTTOM_LEFT: return box.pos() + Vector2D{0.0, box.size().y};
|
||||||
case XDG_POSITIONER_ANCHOR_TOP_RIGHT: return box.pos() + Vector2D{box.size().x, 0};
|
case XDG_POSITIONER_ANCHOR_TOP_RIGHT: return box.pos() + Vector2D{box.size().x, 0.0};
|
||||||
case XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT: return box.pos() + Vector2D{box.size().x, box.size().y};
|
case XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT: return box.pos() + Vector2D{box.size().x, box.size().y};
|
||||||
default: return box.pos();
|
default: return box.pos();
|
||||||
}
|
}
|
||||||
|
@ -555,10 +555,10 @@ CBox CXDGPositionerRules::getPosition(const CBox& constraint, const Vector2D& pa
|
||||||
};
|
};
|
||||||
int edgeCount = countEdges(test);
|
int edgeCount = countEdges(test);
|
||||||
|
|
||||||
if (flipX && edgeCount > countEdges(test.copy().translate(Vector2D{-predictedBox.w - state.anchorRect.w, 0})))
|
if (flipX && edgeCount > countEdges(test.copy().translate(Vector2D{-predictedBox.w - state.anchorRect.w, 0.0})))
|
||||||
test.translate(Vector2D{-predictedBox.w - state.anchorRect.w, 0});
|
test.translate(Vector2D{-predictedBox.w - state.anchorRect.w, 0.0});
|
||||||
if (flipY && edgeCount > countEdges(test.copy().translate(Vector2D{0, -predictedBox.h - state.anchorRect.h})))
|
if (flipY && edgeCount > countEdges(test.copy().translate(Vector2D{0.0, -predictedBox.h - state.anchorRect.h})))
|
||||||
test.translate(Vector2D{0, -predictedBox.h - state.anchorRect.h});
|
test.translate(Vector2D{0.0, -predictedBox.h - state.anchorRect.h});
|
||||||
|
|
||||||
success = test.copy().expand(-1).inside(constraint);
|
success = test.copy().expand(-1).inside(constraint);
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
#include "xdg-shell.hpp"
|
#include "xdg-shell.hpp"
|
||||||
#include "../helpers/Vector2D.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/Box.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/signal/Signal.hpp"
|
#include "../helpers/signal/Signal.hpp"
|
||||||
#include "types/SurfaceRole.hpp"
|
#include "types/SurfaceRole.hpp"
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ CRegion CWLSurfaceResource::accumulateCurrentBufferDamage() {
|
||||||
|
|
||||||
Vector2D trc = current.transform % 2 == 1 ? Vector2D{current.buffer->size.y, current.buffer->size.x} : current.buffer->size;
|
Vector2D trc = current.transform % 2 == 1 ? Vector2D{current.buffer->size.y, current.buffer->size.x} : current.buffer->size;
|
||||||
|
|
||||||
return surfaceDamage.scale(current.scale).transform(wlr_output_transform_invert(current.transform), trc.x, trc.y).add(current.bufferDamage);
|
return surfaceDamage.scale(current.scale).transform(wlTransformToHyprutils(wlr_output_transform_invert(current.transform)), trc.x, trc.y).add(current.bufferDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
CWLCompositorResource::CWLCompositorResource(SP<CWlCompositor> resource_) : resource(resource_) {
|
CWLCompositorResource::CWLCompositorResource(SP<CWlCompositor> resource_) : resource(resource_) {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "../WaylandProtocol.hpp"
|
#include "../WaylandProtocol.hpp"
|
||||||
#include "wayland.hpp"
|
#include "wayland.hpp"
|
||||||
#include "../../helpers/signal/Signal.hpp"
|
#include "../../helpers/signal/Signal.hpp"
|
||||||
#include "../../helpers/Region.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
#include "../types/Buffer.hpp"
|
#include "../types/Buffer.hpp"
|
||||||
#include "../types/SurfaceRole.hpp"
|
#include "../types/SurfaceRole.hpp"
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <wayland-server-protocol.h>
|
#include <wayland-server-protocol.h>
|
||||||
#include "wayland.hpp"
|
#include "wayland.hpp"
|
||||||
#include "../../helpers/signal/Signal.hpp"
|
#include "../../helpers/signal/Signal.hpp"
|
||||||
#include "../../helpers/Vector2D.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
#include "../types/DataDevice.hpp"
|
#include "../types/DataDevice.hpp"
|
||||||
|
|
||||||
class CWLDataDeviceResource;
|
class CWLDataDeviceResource;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <wayland-server-protocol.h>
|
#include <wayland-server-protocol.h>
|
||||||
#include "wayland.hpp"
|
#include "wayland.hpp"
|
||||||
#include "../../helpers/signal/Signal.hpp"
|
#include "../../helpers/signal/Signal.hpp"
|
||||||
#include "../../helpers/Vector2D.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
|
|
||||||
constexpr const char* HL_SEAT_NAME = "Hyprland";
|
constexpr const char* HL_SEAT_NAME = "Hyprland";
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "../WaylandProtocol.hpp"
|
#include "../WaylandProtocol.hpp"
|
||||||
#include "wayland.hpp"
|
#include "wayland.hpp"
|
||||||
#include "../types/Buffer.hpp"
|
#include "../types/Buffer.hpp"
|
||||||
#include "../../helpers/Vector2D.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
|
|
||||||
class CWLSHMPoolResource;
|
class CWLSHMPoolResource;
|
||||||
|
|
||||||
|
|
|
@ -916,7 +916,7 @@ void CHyprOpenGLImpl::scissor(const CBox* pBox, bool transform) {
|
||||||
int w, h;
|
int w, h;
|
||||||
wlr_output_transformed_resolution(m_RenderData.pMonitor->output, &w, &h);
|
wlr_output_transformed_resolution(m_RenderData.pMonitor->output, &w, &h);
|
||||||
|
|
||||||
const auto TR = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
|
const auto TR = wlTransformToHyprutils(wlr_output_transform_invert(m_RenderData.pMonitor->transform));
|
||||||
newBox.transform(TR, w, h);
|
newBox.transform(TR, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1006,8 +1006,8 @@ void CHyprOpenGLImpl::renderRectWithDamage(CBox* box, const CColor& col, CRegion
|
||||||
box = &newBox;
|
box = &newBox;
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, box->pWlr(), wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), newBox.rot,
|
projectBox(matrix, newBox, wlTransformToHyprutils(wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot,
|
||||||
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -1025,7 +1025,7 @@ void CHyprOpenGLImpl::renderRectWithDamage(CBox* box, const CColor& col, CRegion
|
||||||
glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r * col.a, col.g * col.a, col.b * col.a, col.a);
|
glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r * col.a, col.g * col.a, col.b * col.a, col.a);
|
||||||
|
|
||||||
CBox transformedBox = *box;
|
CBox transformedBox = *box;
|
||||||
transformedBox.transform(wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
transformedBox.transform(wlTransformToHyprutils(wlr_output_transform_invert(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||||
m_RenderData.pMonitor->vecTransformedSize.y);
|
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||||
|
@ -1097,9 +1097,9 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, CBox* pB
|
||||||
static auto PDT = CConfigValue<Hyprlang::INT>("debug:damage_tracking");
|
static auto PDT = CConfigValue<Hyprlang::INT>("debug:damage_tracking");
|
||||||
|
|
||||||
// get transform
|
// get transform
|
||||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
const auto TRANSFORM = wlTransformToHyprutils(wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform));
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
projectBox(matrix, newBox, TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -1185,7 +1185,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(SP<CTexture> tex, CBox* pB
|
||||||
}
|
}
|
||||||
|
|
||||||
CBox transformedBox = newBox;
|
CBox transformedBox = newBox;
|
||||||
transformedBox.transform(wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
transformedBox.transform(wlTransformToHyprutils(wlr_output_transform_invert(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||||
m_RenderData.pMonitor->vecTransformedSize.y);
|
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||||
|
@ -1260,9 +1260,9 @@ void CHyprOpenGLImpl::renderTexturePrimitive(SP<CTexture> tex, CBox* pBox) {
|
||||||
m_RenderData.renderModif.applyToBox(newBox);
|
m_RenderData.renderModif.applyToBox(newBox);
|
||||||
|
|
||||||
// get transform
|
// get transform
|
||||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
const auto TRANSFORM = wlTransformToHyprutils(wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform));
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
projectBox(matrix, newBox, TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -1314,9 +1314,9 @@ void CHyprOpenGLImpl::renderTextureMatte(SP<CTexture> tex, CBox* pBox, CFramebuf
|
||||||
m_RenderData.renderModif.applyToBox(newBox);
|
m_RenderData.renderModif.applyToBox(newBox);
|
||||||
|
|
||||||
// get transform
|
// get transform
|
||||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
const auto TRANSFORM = wlTransformToHyprutils(wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform));
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, newBox.pWlr(), TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
projectBox(matrix, newBox, TRANSFORM, newBox.rot, m_RenderData.monitorProjection.data());
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -1372,10 +1372,10 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
|
||||||
// get transforms for the full monitor
|
// get transforms for the full monitor
|
||||||
const auto TRANSFORM = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
|
const auto TRANSFORM = wlTransformToHyprutils(wlr_output_transform_invert(m_RenderData.pMonitor->transform));
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
CBox MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
CBox MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||||
wlr_matrix_project_box(matrix, MONITORBOX.pWlr(), TRANSFORM, 0, m_RenderData.monitorProjection.data());
|
projectBox(matrix, MONITORBOX, TRANSFORM, 0, m_RenderData.monitorProjection.data());
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -1870,8 +1870,8 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in
|
||||||
round += round == 0 ? 0 : scaledBorderSize;
|
round += round == 0 ? 0 : scaledBorderSize;
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, box->pWlr(), wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), newBox.rot,
|
projectBox(matrix, newBox, wlTransformToHyprutils(wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot,
|
||||||
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -1896,7 +1896,7 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in
|
||||||
glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.alpha, a);
|
glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.alpha, a);
|
||||||
|
|
||||||
CBox transformedBox = *box;
|
CBox transformedBox = *box;
|
||||||
transformedBox.transform(wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
transformedBox.transform(wlTransformToHyprutils(wlr_output_transform_invert(m_RenderData.pMonitor->transform)), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||||
m_RenderData.pMonitor->vecTransformedSize.y);
|
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||||
|
@ -2176,8 +2176,8 @@ void CHyprOpenGLImpl::renderRoundedShadow(CBox* box, int round, int range, const
|
||||||
const auto col = color;
|
const auto col = color;
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, box->pWlr(), wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), newBox.rot,
|
projectBox(matrix, newBox, wlTransformToHyprutils(wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform)), newBox.rot,
|
||||||
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
m_RenderData.monitorProjection.data()); // TODO: write own, don't use WLR here
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -2258,7 +2258,7 @@ void CHyprOpenGLImpl::renderMirrored() {
|
||||||
CBox monbox = {0, 0, mirrored->vecTransformedSize.x * scale, mirrored->vecTransformedSize.y * scale};
|
CBox monbox = {0, 0, mirrored->vecTransformedSize.x * scale, mirrored->vecTransformedSize.y * scale};
|
||||||
|
|
||||||
// transform box as it will be drawn on a transformed projection
|
// transform box as it will be drawn on a transformed projection
|
||||||
monbox.transform(mirrored->transform, mirrored->vecTransformedSize.x * scale, mirrored->vecTransformedSize.y * scale);
|
monbox.transform(wlTransformToHyprutils(mirrored->transform), mirrored->vecTransformedSize.x * scale, mirrored->vecTransformedSize.y * scale);
|
||||||
|
|
||||||
monbox.x = (monitor->vecTransformedSize.x - monbox.w) / 2;
|
monbox.x = (monitor->vecTransformedSize.x - monbox.w) / 2;
|
||||||
monbox.y = (monitor->vecTransformedSize.y - monbox.h) / 2;
|
monbox.y = (monitor->vecTransformedSize.y - monbox.h) / 2;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "../helpers/Monitor.hpp"
|
#include "../helpers/Monitor.hpp"
|
||||||
#include "../helpers/Color.hpp"
|
#include "../helpers/Color.hpp"
|
||||||
#include "../helpers/Timer.hpp"
|
#include "../helpers/Timer.hpp"
|
||||||
#include "../helpers/Region.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include "../helpers/Format.hpp"
|
#include "../helpers/Format.hpp"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "Renderer.hpp"
|
#include "Renderer.hpp"
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
#include "../helpers/Region.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../config/ConfigValue.hpp"
|
#include "../config/ConfigValue.hpp"
|
||||||
#include "../managers/CursorManager.hpp"
|
#include "../managers/CursorManager.hpp"
|
||||||
|
@ -1508,15 +1508,15 @@ void CHyprRenderer::setWindowScanoutMode(PHLWINDOW pWindow) {
|
||||||
|
|
||||||
// taken from Sway.
|
// taken from Sway.
|
||||||
// this is just too much of a spaghetti for me to understand
|
// this is just too much of a spaghetti for me to understand
|
||||||
static void applyExclusive(wlr_box& usableArea, uint32_t anchor, int32_t exclusive, int32_t marginTop, int32_t marginRight, int32_t marginBottom, int32_t marginLeft) {
|
static void applyExclusive(CBox& usableArea, uint32_t anchor, int32_t exclusive, int32_t marginTop, int32_t marginRight, int32_t marginBottom, int32_t marginLeft) {
|
||||||
if (exclusive <= 0) {
|
if (exclusive <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct {
|
struct {
|
||||||
uint32_t singular_anchor;
|
uint32_t singular_anchor;
|
||||||
uint32_t anchor_triplet;
|
uint32_t anchor_triplet;
|
||||||
int* positive_axis;
|
double* positive_axis;
|
||||||
int* negative_axis;
|
double* negative_axis;
|
||||||
int margin;
|
int margin;
|
||||||
} edges[] = {
|
} edges[] = {
|
||||||
// Top
|
// Top
|
||||||
|
@ -1640,9 +1640,7 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<PHLL
|
||||||
// Apply
|
// Apply
|
||||||
ls->geometry = box;
|
ls->geometry = box;
|
||||||
|
|
||||||
applyExclusive(*usableArea->pWlr(), PSTATE->anchor, PSTATE->exclusive, PSTATE->margin.top, PSTATE->margin.right, PSTATE->margin.bottom, PSTATE->margin.left);
|
applyExclusive(*usableArea, PSTATE->anchor, PSTATE->exclusive, PSTATE->margin.top, PSTATE->margin.right, PSTATE->margin.bottom, PSTATE->margin.left);
|
||||||
|
|
||||||
usableArea->applyFromWlr();
|
|
||||||
|
|
||||||
if (Vector2D{box.width, box.height} != OLDSIZE)
|
if (Vector2D{box.width, box.height} != OLDSIZE)
|
||||||
ls->layerSurface->configure(box.size());
|
ls->layerSurface->configure(box.size());
|
||||||
|
@ -1820,7 +1818,7 @@ void CHyprRenderer::damageMirrorsWith(CMonitor* pMonitor, const CRegion& pRegion
|
||||||
monbox.y = (monitor->vecTransformedSize.y - monbox.h) / 2;
|
monbox.y = (monitor->vecTransformedSize.y - monbox.h) / 2;
|
||||||
|
|
||||||
wlr_region_scale(transformed.pixman(), transformed.pixman(), scale);
|
wlr_region_scale(transformed.pixman(), transformed.pixman(), scale);
|
||||||
transformed.transform(mirrored->transform, mirrored->vecPixelSize.x * scale, mirrored->vecPixelSize.y * scale);
|
transformed.transform(wlTransformToHyprutils(mirrored->transform), mirrored->vecPixelSize.x * scale, mirrored->vecPixelSize.y * scale);
|
||||||
transformed.translate(Vector2D(monbox.x, monbox.y));
|
transformed.translate(Vector2D(monbox.x, monbox.y));
|
||||||
|
|
||||||
mirror->addDamage(&transformed);
|
mirror->addDamage(&transformed);
|
||||||
|
@ -2234,7 +2232,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
|
|
||||||
if (pMonitor->createdByUser) {
|
if (pMonitor->createdByUser) {
|
||||||
CBox transformedBox = {0, 0, pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y};
|
CBox transformedBox = {0, 0, pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y};
|
||||||
transformedBox.transform(wlr_output_transform_invert(pMonitor->output->transform), pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y);
|
transformedBox.transform(wlTransformToHyprutils(wlr_output_transform_invert(pMonitor->output->transform)), pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
pMonitor->vecPixelSize = Vector2D(transformedBox.width, transformedBox.height);
|
pMonitor->vecPixelSize = Vector2D(transformedBox.width, transformedBox.height);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "OpenGL.hpp"
|
#include "OpenGL.hpp"
|
||||||
#include "Renderbuffer.hpp"
|
#include "Renderbuffer.hpp"
|
||||||
#include "../helpers/Timer.hpp"
|
#include "../helpers/Timer.hpp"
|
||||||
#include "../helpers/Region.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
|
|
||||||
struct SMonitorRule;
|
struct SMonitorRule;
|
||||||
class CWorkspace;
|
class CWorkspace;
|
||||||
|
|
|
@ -55,7 +55,7 @@ CTexture::CTexture(wlr_texture* tex) {
|
||||||
else
|
else
|
||||||
m_iType = TEXTURE_EXTERNAL;
|
m_iType = TEXTURE_EXTERNAL;
|
||||||
|
|
||||||
m_vSize = Vector2D(tex->width, tex->height);
|
m_vSize = Vector2D((int)tex->width, (int)tex->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
CTexture::CTexture(const SDMABUFAttrs& attrs, void* image) {
|
CTexture::CTexture(const SDMABUFAttrs& attrs, void* image) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
class IWLBuffer;
|
class IWLBuffer;
|
||||||
struct SDMABUFAttrs;
|
struct SDMABUFAttrs;
|
||||||
class CRegion;
|
HYPRUTILS_FORWARD(Math, CRegion);
|
||||||
|
|
||||||
enum TEXTURETYPE {
|
enum TEXTURETYPE {
|
||||||
TEXTURE_INVALID, // Invalid
|
TEXTURE_INVALID, // Invalid
|
||||||
|
|
|
@ -26,16 +26,16 @@ class CHyprBorderDecoration : public IHyprWindowDecoration {
|
||||||
virtual std::string getDisplayName();
|
virtual std::string getDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWindowDecorationExtents m_seExtents;
|
SBoxExtents m_seExtents;
|
||||||
SWindowDecorationExtents m_seReportedExtents;
|
SBoxExtents m_seReportedExtents;
|
||||||
|
|
||||||
PHLWINDOWREF m_pWindow;
|
PHLWINDOWREF m_pWindow;
|
||||||
|
|
||||||
Vector2D m_vLastWindowPos;
|
Vector2D m_vLastWindowPos;
|
||||||
Vector2D m_vLastWindowSize;
|
Vector2D m_vLastWindowSize;
|
||||||
|
|
||||||
CBox m_bAssignedGeometry = {0};
|
CBox m_bAssignedGeometry = {0};
|
||||||
|
|
||||||
CBox assignedBoxGlobal();
|
CBox assignedBoxGlobal();
|
||||||
bool doesntWantBorders();
|
bool doesntWantBorders();
|
||||||
};
|
};
|
||||||
|
|
|
@ -130,7 +130,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
|
||||||
const float SHADOWSCALE = std::clamp(*PSHADOWSCALE, 0.f, 1.f);
|
const float SHADOWSCALE = std::clamp(*PSHADOWSCALE, 0.f, 1.f);
|
||||||
|
|
||||||
// scale the box in relation to the center of the box
|
// scale the box in relation to the center of the box
|
||||||
fullBox.scaleFromCenter(SHADOWSCALE).translate(*PSHADOWOFFSET);
|
fullBox.scaleFromCenter(SHADOWSCALE).translate({(*PSHADOWOFFSET).x, (*PSHADOWOFFSET).y});
|
||||||
|
|
||||||
updateWindow(PWINDOW);
|
updateWindow(PWINDOW);
|
||||||
m_vLastWindowPos += WORKSPACEOFFSET;
|
m_vLastWindowPos += WORKSPACEOFFSET;
|
||||||
|
|
|
@ -26,14 +26,14 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
||||||
virtual std::string getDisplayName();
|
virtual std::string getDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWindowDecorationExtents m_seExtents;
|
SBoxExtents m_seExtents;
|
||||||
SWindowDecorationExtents m_seReportedExtents;
|
SBoxExtents m_seReportedExtents;
|
||||||
|
|
||||||
PHLWINDOWREF m_pWindow;
|
PHLWINDOWREF m_pWindow;
|
||||||
|
|
||||||
Vector2D m_vLastWindowPos;
|
Vector2D m_vLastWindowPos;
|
||||||
Vector2D m_vLastWindowSize;
|
Vector2D m_vLastWindowSize;
|
||||||
|
|
||||||
CBox m_bLastWindowBox = {0};
|
CBox m_bLastWindowBox = {0};
|
||||||
CBox m_bLastWindowBoxWithDecos = {0};
|
CBox m_bLastWindowBoxWithDecos = {0};
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,7 +48,7 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
||||||
virtual std::string getDisplayName();
|
virtual std::string getDisplayName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWindowDecorationExtents m_seExtents;
|
SBoxExtents m_seExtents;
|
||||||
|
|
||||||
CBox m_bAssignedBox = {0};
|
CBox m_bAssignedBox = {0};
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,11 @@ Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pW
|
||||||
|
|
||||||
if (EDGESNO == 1) {
|
if (EDGESNO == 1) {
|
||||||
if (TOP)
|
if (TOP)
|
||||||
return wb.pos() + Vector2D{wb.size().x / 2.0, 0};
|
return wb.pos() + Vector2D{wb.size().x / 2.0, 0.0};
|
||||||
else if (BOTTOM)
|
else if (BOTTOM)
|
||||||
return wb.pos() + Vector2D{wb.size().x / 2.0, wb.size().y};
|
return wb.pos() + Vector2D{wb.size().x / 2.0, wb.size().y};
|
||||||
else if (LEFT)
|
else if (LEFT)
|
||||||
return wb.pos() + Vector2D{0, wb.size().y / 2.0};
|
return wb.pos() + Vector2D{0.0, wb.size().y / 2.0};
|
||||||
else if (RIGHT)
|
else if (RIGHT)
|
||||||
return wb.pos() + Vector2D{wb.size().x, wb.size().y / 2.0};
|
return wb.pos() + Vector2D{wb.size().x, wb.size().y / 2.0};
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -45,11 +45,11 @@ Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pW
|
||||||
if (TOP && LEFT)
|
if (TOP && LEFT)
|
||||||
return wb.pos();
|
return wb.pos();
|
||||||
if (TOP && RIGHT)
|
if (TOP && RIGHT)
|
||||||
return wb.pos() + Vector2D{wb.size().x, 0};
|
return wb.pos() + Vector2D{wb.size().x, 0.0};
|
||||||
if (BOTTOM && RIGHT)
|
if (BOTTOM && RIGHT)
|
||||||
return wb.pos() + wb.size();
|
return wb.pos() + wb.size();
|
||||||
if (BOTTOM && LEFT)
|
if (BOTTOM && LEFT)
|
||||||
return wb.pos() + Vector2D{0, wb.size().y};
|
return wb.pos() + Vector2D{0.0, wb.size().y};
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -234,26 +234,26 @@ void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) {
|
||||||
} else if (LEFT) {
|
} else if (LEFT) {
|
||||||
pos = wb.pos() - EDGEPOINT - Vector2D{stickyOffsetXL, -stickyOffsetYT};
|
pos = wb.pos() - EDGEPOINT - Vector2D{stickyOffsetXL, -stickyOffsetYT};
|
||||||
pos.x -= desiredSize;
|
pos.x -= desiredSize;
|
||||||
size = {desiredSize, wb.size().y + stickyOffsetYB + stickyOffsetYT};
|
size = {(double)desiredSize, wb.size().y + stickyOffsetYB + stickyOffsetYT};
|
||||||
|
|
||||||
if (SOLID)
|
if (SOLID)
|
||||||
stickyOffsetXL += desiredSize;
|
stickyOffsetXL += desiredSize;
|
||||||
} else if (RIGHT) {
|
} else if (RIGHT) {
|
||||||
pos = wb.pos() + Vector2D{wb.size().x, 0} - EDGEPOINT + Vector2D{stickyOffsetXR, -stickyOffsetYT};
|
pos = wb.pos() + Vector2D{wb.size().x, 0.0} - EDGEPOINT + Vector2D{stickyOffsetXR, -stickyOffsetYT};
|
||||||
size = {desiredSize, wb.size().y + stickyOffsetYB + stickyOffsetYT};
|
size = {(double)desiredSize, wb.size().y + stickyOffsetYB + stickyOffsetYT};
|
||||||
|
|
||||||
if (SOLID)
|
if (SOLID)
|
||||||
stickyOffsetXR += desiredSize;
|
stickyOffsetXR += desiredSize;
|
||||||
} else if (TOP) {
|
} else if (TOP) {
|
||||||
pos = wb.pos() - EDGEPOINT - Vector2D{stickyOffsetXL, stickyOffsetYT};
|
pos = wb.pos() - EDGEPOINT - Vector2D{stickyOffsetXL, stickyOffsetYT};
|
||||||
pos.y -= desiredSize;
|
pos.y -= desiredSize;
|
||||||
size = {wb.size().x + stickyOffsetXL + stickyOffsetXR, desiredSize};
|
size = {wb.size().x + stickyOffsetXL + stickyOffsetXR, (double)desiredSize};
|
||||||
|
|
||||||
if (SOLID)
|
if (SOLID)
|
||||||
stickyOffsetYT += desiredSize;
|
stickyOffsetYT += desiredSize;
|
||||||
} else {
|
} else {
|
||||||
pos = wb.pos() + Vector2D{0, wb.size().y} - EDGEPOINT - Vector2D{stickyOffsetXL, stickyOffsetYB};
|
pos = wb.pos() + Vector2D{0.0, wb.size().y} - EDGEPOINT - Vector2D{stickyOffsetXL, stickyOffsetYB};
|
||||||
size = {wb.size().x + stickyOffsetXL + stickyOffsetXR, desiredSize};
|
size = {wb.size().x + stickyOffsetXL + stickyOffsetXR, (double)desiredSize};
|
||||||
|
|
||||||
if (SOLID)
|
if (SOLID)
|
||||||
stickyOffsetYB += desiredSize;
|
stickyOffsetYB += desiredSize;
|
||||||
|
@ -271,7 +271,7 @@ void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WINDOWDATA->extents != SWindowDecorationExtents{{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}}) {
|
if (WINDOWDATA->extents != SBoxExtents{{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}}) {
|
||||||
WINDOWDATA->extents = {{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}};
|
WINDOWDATA->extents = {{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}};
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateWindow(pWindow);
|
g_pLayoutManager->getCurrentLayout()->recalculateWindow(pWindow);
|
||||||
}
|
}
|
||||||
|
@ -286,14 +286,14 @@ void CDecorationPositioner::onWindowMap(PHLWINDOW pWindow) {
|
||||||
m_mWindowDatas[pWindow] = {};
|
m_mWindowDatas[pWindow] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOW pWindow) {
|
SBoxExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOW pWindow) {
|
||||||
try {
|
try {
|
||||||
const auto E = m_mWindowDatas.at(pWindow);
|
const auto E = m_mWindowDatas.at(pWindow);
|
||||||
return E.reserved;
|
return E.reserved;
|
||||||
} catch (std::out_of_range& e) { return {}; }
|
} catch (std::out_of_range& e) { return {}; }
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly) {
|
SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly) {
|
||||||
CBox accum = pWindow->getWindowMainSurfaceBox();
|
CBox accum = pWindow->getWindowMainSurfaceBox();
|
||||||
|
|
||||||
for (auto& data : m_vWindowPositioningDatas) {
|
for (auto& data : m_vWindowPositioningDatas) {
|
||||||
|
@ -317,7 +317,7 @@ SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(PHLWI
|
||||||
decoBox.translate(EDGEPOINT);
|
decoBox.translate(EDGEPOINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents extentsToAdd;
|
SBoxExtents extentsToAdd;
|
||||||
|
|
||||||
if (decoBox.x < accum.x)
|
if (decoBox.x < accum.x)
|
||||||
extentsToAdd.topLeft.x = accum.x - decoBox.x;
|
extentsToAdd.topLeft.x = accum.x - decoBox.x;
|
||||||
|
@ -355,7 +355,7 @@ CBox CDecorationPositioner::getBoxWithIncludedDecos(PHLWINDOW pWindow) {
|
||||||
decoBox.translate(EDGEPOINT);
|
decoBox.translate(EDGEPOINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents extentsToAdd;
|
SBoxExtents extentsToAdd;
|
||||||
|
|
||||||
if (decoBox.x < accum.x)
|
if (decoBox.x < accum.x)
|
||||||
extentsToAdd.topLeft.x = accum.x - decoBox.x;
|
extentsToAdd.topLeft.x = accum.x - decoBox.x;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "../../helpers/Box.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
#include "../../desktop/DesktopTypes.hpp"
|
#include "../../desktop/DesktopTypes.hpp"
|
||||||
|
|
||||||
class CWindow;
|
class CWindow;
|
||||||
|
@ -37,7 +37,7 @@ struct SDecorationPositioningInfo {
|
||||||
eDecorationPositioningPolicy policy = DECORATION_POSITION_ABSOLUTE;
|
eDecorationPositioningPolicy policy = DECORATION_POSITION_ABSOLUTE;
|
||||||
uint32_t edges = 0; // enum eDecorationEdges
|
uint32_t edges = 0; // enum eDecorationEdges
|
||||||
uint32_t priority = 10; // priority, decos will be evaluated high -> low
|
uint32_t priority = 10; // priority, decos will be evaluated high -> low
|
||||||
SWindowDecorationExtents desiredExtents;
|
SBoxExtents desiredExtents;
|
||||||
bool reserved = false; // if true, geometry will use reserved area
|
bool reserved = false; // if true, geometry will use reserved area
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@ class CDecorationPositioner {
|
||||||
Vector2D getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pWindow);
|
Vector2D getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pWindow);
|
||||||
|
|
||||||
// called on resize, or insert/removal of a new deco
|
// called on resize, or insert/removal of a new deco
|
||||||
void onWindowUpdate(PHLWINDOW pWindow);
|
void onWindowUpdate(PHLWINDOW pWindow);
|
||||||
void uncacheDecoration(IHyprWindowDecoration* deco);
|
void uncacheDecoration(IHyprWindowDecoration* deco);
|
||||||
SWindowDecorationExtents getWindowDecorationReserved(PHLWINDOW pWindow);
|
SBoxExtents getWindowDecorationReserved(PHLWINDOW pWindow);
|
||||||
SWindowDecorationExtents getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly = false);
|
SBoxExtents getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly = false);
|
||||||
CBox getBoxWithIncludedDecos(PHLWINDOW pWindow);
|
CBox getBoxWithIncludedDecos(PHLWINDOW pWindow);
|
||||||
void repositionDeco(IHyprWindowDecoration* deco);
|
void repositionDeco(IHyprWindowDecoration* deco);
|
||||||
CBox getWindowDecorationBox(IHyprWindowDecoration* deco);
|
CBox getWindowDecorationBox(IHyprWindowDecoration* deco);
|
||||||
void forceRecalcFor(PHLWINDOW pWindow);
|
void forceRecalcFor(PHLWINDOW pWindow);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SWindowPositioningData {
|
struct SWindowPositioningData {
|
||||||
|
@ -81,10 +81,10 @@ class CDecorationPositioner {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SWindowData {
|
struct SWindowData {
|
||||||
Vector2D lastWindowSize = {};
|
Vector2D lastWindowSize = {};
|
||||||
SWindowDecorationExtents reserved = {};
|
SBoxExtents reserved = {};
|
||||||
SWindowDecorationExtents extents = {};
|
SBoxExtents extents = {};
|
||||||
bool needsRecalc = false;
|
bool needsRecalc = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<PHLWINDOWREF, SWindowData> m_mWindowDatas;
|
std::map<PHLWINDOWREF, SWindowData> m_mWindowDatas;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <any>
|
#include <any>
|
||||||
#include "../../defines.hpp"
|
#include "../../defines.hpp"
|
||||||
#include "../../helpers/Region.hpp"
|
#include "../../helpers/math/Math.hpp"
|
||||||
#include "DecorationPositioner.hpp"
|
#include "DecorationPositioner.hpp"
|
||||||
|
|
||||||
enum eDecorationType {
|
enum eDecorationType {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "../helpers/WLListener.hpp"
|
#include "../helpers/WLListener.hpp"
|
||||||
#include "../helpers/signal/Signal.hpp"
|
#include "../helpers/signal/Signal.hpp"
|
||||||
#include "../helpers/Box.hpp"
|
#include "../helpers/math/Math.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class CWLSurfaceResource;
|
class CWLSurfaceResource;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "helpers/Vector2D.hpp"
|
#include "helpers/math/Math.hpp"
|
||||||
#ifndef NO_XWAYLAND
|
#ifndef NO_XWAYLAND
|
||||||
|
|
||||||
#include "XWayland.hpp"
|
#include "XWayland.hpp"
|
||||||
|
|
Loading…
Reference in a new issue