mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-29 16:26:00 +01:00
parent
3785defaf1
commit
0dbd997003
7 changed files with 114 additions and 21 deletions
|
@ -2530,5 +2530,10 @@ void CCompositor::arrangeMonitors() {
|
||||||
Debug::log(LOG, "arrangeMonitors: {} xwayland [{}, {:.2f}]", m->szName, maxOffset, 0.f);
|
Debug::log(LOG, "arrangeMonitors: {} xwayland [{}, {:.2f}]", m->szName, maxOffset, 0.f);
|
||||||
m->vecXWaylandPosition = {maxOffset, 0};
|
m->vecXWaylandPosition = {maxOffset, 0};
|
||||||
maxOffset += (*PXWLFORCESCALEZERO ? m->vecTransformedSize.x : m->vecSize.x);
|
maxOffset += (*PXWLFORCESCALEZERO ? m->vecTransformedSize.x : m->vecSize.x);
|
||||||
|
|
||||||
|
if (*PXWLFORCESCALEZERO)
|
||||||
|
m->xwaylandScale = m->scale;
|
||||||
|
else
|
||||||
|
m->xwaylandScale = 1.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ class CMonitor {
|
||||||
bool scheduledRecalc = false;
|
bool scheduledRecalc = false;
|
||||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
bool gammaChanged = false;
|
bool gammaChanged = false;
|
||||||
|
float xwaylandScale = 1.f;
|
||||||
|
|
||||||
bool dpmsStatus = true;
|
bool dpmsStatus = true;
|
||||||
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
|
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Region.hpp"
|
#include "Region.hpp"
|
||||||
#include <wlr/util/box.h>
|
#include <wlr/util/box.h>
|
||||||
|
#include <wlr/util/region.h>
|
||||||
|
|
||||||
CRegion::CRegion() {
|
CRegion::CRegion() {
|
||||||
pixman_region32_init(&m_rRegion);
|
pixman_region32_init(&m_rRegion);
|
||||||
|
@ -81,6 +82,11 @@ CRegion& CRegion::translate(const Vector2D& vec) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CRegion& CRegion::scale(float scale) {
|
||||||
|
wlr_region_scale(&m_rRegion, &m_rRegion, scale);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<pixman_box32_t> CRegion::getRects() const {
|
std::vector<pixman_box32_t> CRegion::getRects() const {
|
||||||
std::vector<pixman_box32_t> result;
|
std::vector<pixman_box32_t> result;
|
||||||
|
|
||||||
|
@ -97,15 +103,15 @@ wlr_box CRegion::getExtents() {
|
||||||
return {box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1};
|
return {box->x1, box->y1, box->x2 - box->x1, box->y2 - box->y1};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRegion::containsPoint(const Vector2D& vec) {
|
bool CRegion::containsPoint(const Vector2D& vec) const {
|
||||||
return pixman_region32_contains_point(&m_rRegion, vec.x, vec.y, nullptr);
|
return pixman_region32_contains_point(&m_rRegion, vec.x, vec.y, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRegion::empty() {
|
bool CRegion::empty() const {
|
||||||
return !pixman_region32_not_empty(&m_rRegion);
|
return !pixman_region32_not_empty(&m_rRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D CRegion::closestPoint(const Vector2D& vec) {
|
Vector2D CRegion::closestPoint(const Vector2D& vec) const {
|
||||||
double bestDist = __FLT_MAX__;
|
double bestDist = __FLT_MAX__;
|
||||||
Vector2D leader = vec;
|
Vector2D leader = vec;
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,11 @@ class CRegion {
|
||||||
CRegion& intersect(double x, double y, double w, double h);
|
CRegion& intersect(double x, double y, double w, double h);
|
||||||
CRegion& translate(const Vector2D& vec);
|
CRegion& translate(const Vector2D& vec);
|
||||||
CRegion& invert(pixman_box32_t* box);
|
CRegion& invert(pixman_box32_t* box);
|
||||||
|
CRegion& scale(float scale);
|
||||||
wlr_box getExtents();
|
wlr_box getExtents();
|
||||||
bool containsPoint(const Vector2D& vec);
|
bool containsPoint(const Vector2D& vec) const;
|
||||||
bool empty();
|
bool empty() const;
|
||||||
Vector2D closestPoint(const Vector2D& vec);
|
Vector2D closestPoint(const Vector2D& vec) const;
|
||||||
|
|
||||||
std::vector<pixman_box32_t> getRects() const;
|
std::vector<pixman_box32_t> getRects() const;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "WLClasses.hpp"
|
#include "WLClasses.hpp"
|
||||||
#include "../config/ConfigManager.hpp"
|
#include "../config/ConfigManager.hpp"
|
||||||
|
#include "../Compositor.hpp"
|
||||||
|
|
||||||
SLayerSurface::SLayerSurface() {
|
SLayerSurface::SLayerSurface() {
|
||||||
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
|
alpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_ENTIRE);
|
||||||
|
@ -38,3 +39,79 @@ void SLayerSurface::applyRules() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CRegion SConstraint::getLogicCoordsRegion() {
|
||||||
|
CRegion result;
|
||||||
|
|
||||||
|
if (!constraint)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface);
|
||||||
|
|
||||||
|
if (!PWINDOWOWNER)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
result.add(&constraint->region); // surface-local coords
|
||||||
|
|
||||||
|
if (!PWINDOWOWNER->m_bIsX11) {
|
||||||
|
result.translate(PWINDOWOWNER->m_vRealPosition.goalv());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto COORDS = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealPosition.goalv() :
|
||||||
|
g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y});
|
||||||
|
|
||||||
|
const auto PMONITOR = PWINDOWOWNER->m_bIsMapped ? g_pCompositor->getMonitorFromID(PWINDOWOWNER->m_iMonitorID) : g_pCompositor->getMonitorFromVector(COORDS);
|
||||||
|
|
||||||
|
if (!PMONITOR)
|
||||||
|
return CRegion{};
|
||||||
|
|
||||||
|
result.scale(PMONITOR->xwaylandScale);
|
||||||
|
|
||||||
|
result.translate(COORDS);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D SConstraint::getLogicConstraintPos() {
|
||||||
|
if (!constraint)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface);
|
||||||
|
|
||||||
|
if (!PWINDOWOWNER)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
if (!PWINDOWOWNER->m_bIsX11)
|
||||||
|
return PWINDOWOWNER->m_vRealPosition.goalv();
|
||||||
|
|
||||||
|
const auto COORDS = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealPosition.goalv() :
|
||||||
|
g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y});
|
||||||
|
|
||||||
|
return COORDS;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2D SConstraint::getLogicConstraintSize() {
|
||||||
|
if (!constraint)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const auto PWINDOWOWNER = g_pCompositor->getWindowFromSurface(constraint->surface);
|
||||||
|
|
||||||
|
if (!PWINDOWOWNER)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
if (!PWINDOWOWNER->m_bIsX11)
|
||||||
|
return PWINDOWOWNER->m_vRealSize.goalv();
|
||||||
|
|
||||||
|
const auto PMONITOR = PWINDOWOWNER->m_bIsMapped ?
|
||||||
|
g_pCompositor->getMonitorFromID(PWINDOWOWNER->m_iMonitorID) :
|
||||||
|
g_pCompositor->getMonitorFromVector(g_pXWaylandManager->xwaylandToWaylandCoords({PWINDOWOWNER->m_uSurface.xwayland->x, PWINDOWOWNER->m_uSurface.xwayland->y}));
|
||||||
|
|
||||||
|
if (!PMONITOR)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const auto SIZE = PWINDOWOWNER->m_bIsMapped ? PWINDOWOWNER->m_vRealSize.goalv() :
|
||||||
|
Vector2D{PWINDOWOWNER->m_uSurface.xwayland->width, PWINDOWOWNER->m_uSurface.xwayland->height} * PMONITOR->xwaylandScale;
|
||||||
|
|
||||||
|
return SIZE;
|
||||||
|
}
|
|
@ -174,6 +174,10 @@ struct SConstraint {
|
||||||
DYNLISTENER(setConstraintRegion);
|
DYNLISTENER(setConstraintRegion);
|
||||||
DYNLISTENER(destroyConstraint);
|
DYNLISTENER(destroyConstraint);
|
||||||
|
|
||||||
|
CRegion getLogicCoordsRegion();
|
||||||
|
Vector2D getLogicConstraintPos();
|
||||||
|
Vector2D getLogicConstraintSize();
|
||||||
|
|
||||||
bool operator==(const SConstraint& b) const {
|
bool operator==(const SConstraint& b) const {
|
||||||
return constraint == b.constraint;
|
return constraint == b.constraint;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,26 +144,25 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
} else {
|
} else {
|
||||||
// Native Wayland apps know how 2 constrain themselves.
|
// Native Wayland apps know how 2 constrain themselves.
|
||||||
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
|
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
|
||||||
const auto CONSTRAINTPOS =
|
const auto CONSTRAINTPOS = PCONSTRAINT->getLogicConstraintPos();
|
||||||
CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec();
|
const auto CONSTRAINTSIZE = PCONSTRAINT->getLogicConstraintSize();
|
||||||
const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) :
|
|
||||||
CONSTRAINTWINDOW->m_vRealSize.vec();
|
|
||||||
|
|
||||||
if (g_pCompositor->m_sSeat.mouse->currentConstraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) {
|
if (g_pCompositor->m_sSeat.mouse->currentConstraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) {
|
||||||
// we just snap the cursor to where it should be.
|
// we just snap the cursor to where it should be.
|
||||||
|
|
||||||
Vector2D hint = {PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y};
|
if (PCONSTRAINT->hintSet)
|
||||||
|
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, CONSTRAINTPOS.x + PCONSTRAINT->positionHint.x,
|
||||||
if (hint != Vector2D{-1, -1})
|
CONSTRAINTPOS.y + PCONSTRAINT->positionHint.y);
|
||||||
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, CONSTRAINTPOS.x + hint.x, CONSTRAINTPOS.y + hint.y);
|
|
||||||
|
|
||||||
return; // don't process anything else, the cursor is locked. The surface should not receive any further events.
|
return; // don't process anything else, the cursor is locked. The surface should not receive any further events.
|
||||||
// these are usually FPS games. They will use the relative motion.
|
// these are usually FPS games. They will use the relative motion.
|
||||||
} else {
|
} else {
|
||||||
// we restrict the cursor to the confined region
|
// we restrict the cursor to the confined region
|
||||||
if (!pixman_region32_contains_point(&PCONSTRAINT->constraint->region, mouseCoords.x - CONSTRAINTPOS.x, mouseCoords.y - CONSTRAINTPOS.y, nullptr)) {
|
const auto REGION = PCONSTRAINT->getLogicCoordsRegion();
|
||||||
|
|
||||||
|
if (!REGION.containsPoint(mouseCoords)) {
|
||||||
if (g_pCompositor->m_sSeat.mouse->constraintActive) {
|
if (g_pCompositor->m_sSeat.mouse->constraintActive) {
|
||||||
const auto CLOSEST = CRegion(&PCONSTRAINT->constraint->region).closestPoint(mouseCoords - CONSTRAINTPOS) + CONSTRAINTPOS;
|
const auto CLOSEST = REGION.closestPoint(mouseCoords);
|
||||||
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, NULL, CLOSEST.x, CLOSEST.y);
|
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, NULL, CLOSEST.x, CLOSEST.y);
|
||||||
mouseCoords = getMouseCoordsInternal();
|
mouseCoords = getMouseCoordsInternal();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue