windows: refactor class member vars (#10168)

This commit is contained in:
davc0n 2025-04-28 22:25:22 +02:00 committed by GitHub
parent c505eb55ff
commit 2118440488
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 2124 additions and 2134 deletions

View file

@ -54,8 +54,7 @@ void CPopup::initAllSignals() {
if (!m_resource) {
if (!m_windowOwner.expired())
m_listeners.newPopup =
m_windowOwner->m_pXDGSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
m_listeners.newPopup = m_windowOwner->m_xdgSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
else if (!m_layerOwner.expired())
m_listeners.newPopup =
m_layerOwner->m_layerSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
@ -172,7 +171,7 @@ void CPopup::onCommit(bool ignoreSiblings) {
return;
}
if (!m_windowOwner.expired() && (!m_windowOwner->m_bIsMapped || !m_windowOwner->m_pWorkspace->m_visible)) {
if (!m_windowOwner.expired() && (!m_windowOwner->m_isMapped || !m_windowOwner->m_workspace->m_visible)) {
m_lastSize = m_resource->surface->surface->current.size;
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
@ -231,7 +230,7 @@ void CPopup::reposition() {
SP<CWLSurface> CPopup::getT1Owner() {
if (m_windowOwner)
return m_windowOwner->m_pWLSurface;
return m_windowOwner->m_wlSurface;
else
return m_layerOwner->m_surface;
}
@ -266,7 +265,7 @@ Vector2D CPopup::localToGlobal(const Vector2D& rel) {
Vector2D CPopup::t1ParentCoords() {
if (!m_windowOwner.expired())
return m_windowOwner->m_vRealPosition->value();
return m_windowOwner->m_realPosition->value();
if (!m_layerOwner.expired())
return m_layerOwner->m_realPosition->value();
@ -301,7 +300,7 @@ Vector2D CPopup::size() {
void CPopup::sendScale() {
if (!m_windowOwner.expired())
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_windowOwner->m_pWLSurface->m_lastScaleFloat);
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_windowOwner->m_wlSurface->m_lastScaleFloat);
else if (!m_layerOwner.expired())
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_layerOwner->m_surface->m_lastScaleFloat);
else

View file

@ -13,7 +13,7 @@ UP<CSubsurface> CSubsurface::create(PHLWINDOW pOwner) {
subsurface->m_self = subsurface;
subsurface->initSignals();
subsurface->initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
subsurface->initExistingSubsurfaces(pOwner->m_wlSurface->resource());
return subsurface;
}
@ -60,7 +60,7 @@ void CSubsurface::initSignals() {
m_subsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
} else {
if (m_windowParent)
m_listeners.newSubsurface = m_windowParent->m_pWLSurface->resource()->events.newSubsurface.registerListener(
m_listeners.newSubsurface = m_windowParent->m_wlSurface->resource()->events.newSubsurface.registerListener(
[this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
else if (m_popupParent)
m_listeners.newSubsurface =
@ -74,7 +74,7 @@ void CSubsurface::checkSiblingDamage() {
if (!m_parent)
return; // ??????????
const double SCALE = m_windowParent.lock() && m_windowParent->m_bIsX11 ? 1.0 / m_windowParent->m_fX11SurfaceScaledBy : 1.0;
const double SCALE = m_windowParent.lock() && m_windowParent->m_isX11 ? 1.0 / m_windowParent->m_X11SurfaceScaledBy : 1.0;
for (auto const& n : m_parent->m_children) {
if (n.get() == this)
@ -94,7 +94,7 @@ void CSubsurface::recheckDamageForSubsurfaces() {
void CSubsurface::onCommit() {
// no damaging if it's not visible
if (!m_windowParent.expired() && (!m_windowParent->m_bIsMapped || !m_windowParent->m_pWorkspace->m_visible)) {
if (!m_windowParent.expired() && (!m_windowParent->m_isMapped || !m_windowParent->m_workspace->m_visible)) {
m_lastSize = m_wlSurface->resource()->current.size;
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
@ -110,7 +110,7 @@ void CSubsurface::onCommit() {
if (m_popupParent && !m_popupParent->inert() && m_popupParent->m_wlSurface)
m_popupParent->recheckTree();
if (!m_windowParent.expired()) // I hate you firefox why are you doing this
m_windowParent->m_pPopupHead->recheckTree();
m_windowParent->m_popupHead->recheckTree();
// I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
checkSiblingDamage();
@ -191,7 +191,7 @@ Vector2D CSubsurface::coordsGlobal() {
Vector2D coords = coordsRelativeToParent();
if (!m_windowParent.expired())
coords += m_windowParent->m_vRealPosition->value();
coords += m_windowParent->m_realPosition->value();
else if (m_popupParent)
coords += m_popupParent->coordsGlobal();

View file

@ -64,7 +64,7 @@ bool CWLSurface::small() const {
const auto O = m_windowOwner.lock();
return O->m_vReportedSize.x > m_resource->current.size.x + 1 || O->m_vReportedSize.y > m_resource->current.size.y + 1;
return O->m_reportedSize.x > m_resource->current.size.x + 1 || O->m_reportedSize.y > m_resource->current.size.y + 1;
}
Vector2D CWLSurface::correctSmallVec() const {
@ -74,7 +74,7 @@ Vector2D CWLSurface::correctSmallVec() const {
const auto SIZE = getViewporterCorrectedSize();
const auto O = m_windowOwner.lock();
return Vector2D{(O->m_vReportedSize.x - SIZE.x) / 2, (O->m_vReportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_vRealSize->value() / O->m_vReportedSize);
return Vector2D{(O->m_reportedSize.x - SIZE.x) / 2, (O->m_reportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_realSize->value() / O->m_reportedSize);
}
Vector2D CWLSurface::correctSmallVecBuf() const {
@ -121,7 +121,7 @@ CRegion CWLSurface::computeDamage() const {
damage.scale(SCALE);
if (m_windowOwner)
damage.scale(m_windowOwner->m_fX11SurfaceScaledBy); // fix xwayland:force_zero_scaling stuff that will be fucked by the above a bit
damage.scale(m_windowOwner->m_X11SurfaceScaledBy); // fix xwayland:force_zero_scaling stuff that will be fucked by the above a bit
return damage;
}

File diff suppressed because it is too large Load diff

View file

@ -67,14 +67,14 @@ enum eSuppressEvents : uint8_t {
class IWindowTransformer;
struct SAlphaValue {
float m_fAlpha;
bool m_bOverride;
float alpha;
bool override;
float applyAlpha(float alpha) const {
if (m_bOverride)
return m_fAlpha;
if (override)
return alpha;
else
return m_fAlpha * alpha;
return alpha * alpha;
};
};
@ -145,154 +145,151 @@ class CWindow {
public:
~CWindow();
SP<CWLSurface> m_pWLSurface;
SP<CWLSurface> m_wlSurface;
struct {
CSignal destroy;
} events;
} m_events;
WP<CXDGSurfaceResource> m_pXDGSurface;
WP<CXWaylandSurface> m_pXWaylandSurface;
WP<CXDGSurfaceResource> m_xdgSurface;
WP<CXWaylandSurface> m_xwaylandSurface;
// this is the position and size of the "bounding box"
Vector2D m_vPosition = Vector2D(0, 0);
Vector2D m_vSize = Vector2D(0, 0);
Vector2D m_position = Vector2D(0, 0);
Vector2D m_size = Vector2D(0, 0);
// this is the real position and size used to draw the thing
PHLANIMVAR<Vector2D> m_vRealPosition;
PHLANIMVAR<Vector2D> m_vRealSize;
PHLANIMVAR<Vector2D> m_realPosition;
PHLANIMVAR<Vector2D> m_realSize;
// for not spamming the protocols
Vector2D m_vReportedPosition;
Vector2D m_vReportedSize;
Vector2D m_vPendingReportedSize;
std::optional<std::pair<uint32_t, Vector2D>> m_pPendingSizeAck;
std::vector<std::pair<uint32_t, Vector2D>> m_vPendingSizeAcks;
Vector2D m_reportedPosition;
Vector2D m_reportedSize;
Vector2D m_pendingReportedSize;
std::optional<std::pair<uint32_t, Vector2D>> m_pendingSizeAck;
std::vector<std::pair<uint32_t, Vector2D>> m_pendingSizeAcks;
// for restoring floating statuses
Vector2D m_vLastFloatingSize;
Vector2D m_vLastFloatingPosition;
Vector2D m_lastFloatingSize;
Vector2D m_lastFloatingPosition;
// for floating window offset in workspace animations
Vector2D m_vFloatingOffset = Vector2D(0, 0);
Vector2D m_floatingOffset = Vector2D(0, 0);
// this is used for pseudotiling
bool m_bIsPseudotiled = false;
Vector2D m_vPseudoSize = Vector2D(1280, 720);
bool m_isPseudotiled = false;
Vector2D m_pseudoSize = Vector2D(1280, 720);
// for recovering relative cursor position
Vector2D m_vRelativeCursorCoordsOnLastWarp = Vector2D(-1, -1);
Vector2D m_relativeCursorCoordsOnLastWarp = Vector2D(-1, -1);
bool m_bFirstMap = false; // for layouts
bool m_bIsFloating = false;
bool m_bDraggingTiled = false; // for dragging around tiled windows
bool m_bWasMaximized = false;
SFullscreenState m_sFullscreenState = {.internal = FSMODE_NONE, .client = FSMODE_NONE};
std::string m_szTitle = "";
std::string m_szClass = "";
std::string m_szInitialTitle = "";
std::string m_szInitialClass = "";
PHLWORKSPACE m_pWorkspace;
PHLMONITORREF m_pMonitor;
bool m_firstMap = false; // for layouts
bool m_isFloating = false;
bool m_draggingTiled = false; // for dragging around tiled windows
SFullscreenState m_fullscreenState = {.internal = FSMODE_NONE, .client = FSMODE_NONE};
std::string m_title = "";
std::string m_class = "";
std::string m_initialTitle = "";
std::string m_initialClass = "";
PHLWORKSPACE m_workspace;
PHLMONITORREF m_monitor;
bool m_bIsMapped = false;
bool m_isMapped = false;
bool m_bRequestsFloat = false;
bool m_requestsFloat = false;
// This is for fullscreen apps
bool m_bCreatedOverFullscreen = false;
bool m_createdOverFullscreen = false;
// XWayland stuff
bool m_bIsX11 = false;
PHLWINDOWREF m_pX11Parent;
bool m_bX11DoesntWantBorders = false;
bool m_bX11ShouldntFocus = false;
float m_fX11SurfaceScaledBy = 1.f;
bool m_isX11 = false;
bool m_X11DoesntWantBorders = false;
bool m_X11ShouldntFocus = false;
float m_X11SurfaceScaledBy = 1.f;
//
// For nofocus
bool m_bNoInitialFocus = false;
bool m_noInitialFocus = false;
// Fullscreen and Maximize
bool m_bWantsInitialFullscreen = false;
MONITORID m_iWantsInitialFullscreenMonitor = MONITOR_INVALID;
bool m_wantsInitialFullscreen = false;
MONITORID m_wantsInitialFullscreenMonitor = MONITOR_INVALID;
// bitfield eSuppressEvents
uint64_t m_eSuppressedEvents = SUPPRESS_NONE;
// bitfield suppressEvents
uint64_t m_suppressedEvents = SUPPRESS_NONE;
// desktop components
UP<CSubsurface> m_pSubsurfaceHead;
UP<CPopup> m_pPopupHead;
UP<CSubsurface> m_subsurfaceHead;
UP<CPopup> m_popupHead;
// Animated border
CGradientValueData m_cRealBorderColor = {0};
CGradientValueData m_cRealBorderColorPrevious = {0};
PHLANIMVAR<float> m_fBorderFadeAnimationProgress;
PHLANIMVAR<float> m_fBorderAngleAnimationProgress;
CGradientValueData m_realBorderColor = {0};
CGradientValueData m_realBorderColorPrevious = {0};
PHLANIMVAR<float> m_borderFadeAnimationProgress;
PHLANIMVAR<float> m_borderAngleAnimationProgress;
// Fade in-out
PHLANIMVAR<float> m_fAlpha;
bool m_bFadingOut = false;
bool m_bReadyToDelete = false;
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
Vector2D m_vOriginalClosedSize; // drawing the closing animations
SBoxExtents m_eOriginalClosedExtents;
bool m_bAnimatingIn = false;
PHLANIMVAR<float> m_alpha;
bool m_fadingOut = false;
bool m_readyToDelete = false;
Vector2D m_originalClosedPos; // these will be used for calculations later on in
Vector2D m_originalClosedSize; // drawing the closing animations
SBoxExtents m_originalClosedExtents;
bool m_animatingIn = false;
// For pinned (sticky) windows
bool m_bPinned = false;
bool m_pinned = false;
// For preserving pinned state when fullscreening a pinned window
bool m_bPinFullscreened = false;
bool m_pinFullscreened = false;
// urgency hint
bool m_bIsUrgent = false;
bool m_isUrgent = false;
// for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
PHLWINDOWREF m_pLastCycledWindow;
PHLWINDOWREF m_lastCycledWindow;
// Window decorations
// TODO: make this a SP.
std::vector<UP<IHyprWindowDecoration>> m_dWindowDecorations;
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
std::vector<UP<IHyprWindowDecoration>> m_windowDecorations;
std::vector<IHyprWindowDecoration*> m_decosToRemove;
// Special render data, rules, etc
SWindowData m_sWindowData;
SWindowData m_windowData;
// Transformers
std::vector<UP<IWindowTransformer>> m_vTransformers;
std::vector<UP<IWindowTransformer>> m_transformers;
// for alpha
PHLANIMVAR<float> m_fActiveInactiveAlpha;
PHLANIMVAR<float> m_fMovingFromWorkspaceAlpha;
PHLANIMVAR<float> m_activeInactiveAlpha;
PHLANIMVAR<float> m_movingFromWorkspaceAlpha;
// animated shadow color
PHLANIMVAR<CHyprColor> m_cRealShadowColor;
PHLANIMVAR<CHyprColor> m_realShadowColor;
// animated tint
PHLANIMVAR<float> m_fDimPercent;
PHLANIMVAR<float> m_dimPercent;
// animate moving to an invisible workspace
int m_iMonitorMovedFrom = -1; // -1 means not moving
PHLANIMVAR<float> m_fMovingToWorkspaceAlpha;
int m_monitorMovedFrom = -1; // -1 means not moving
PHLANIMVAR<float> m_movingToWorkspaceAlpha;
// swallowing
PHLWINDOWREF m_pSwallowed;
bool m_bCurrentlySwallowed = false;
bool m_bGroupSwallowed = false;
PHLWINDOWREF m_swallowed;
bool m_currentlySwallowed = false;
bool m_groupSwallowed = false;
// focus stuff
bool m_bStayFocused = false;
bool m_stayFocused = false;
// for toplevel monitor events
MONITORID m_iLastToplevelMonitorID = -1;
MONITORID m_iLastSurfaceMonitorID = -1;
MONITORID m_lastSurfaceMonitorID = -1;
// for idle inhibiting windows
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
eIdleInhibitMode m_idleInhibitMode = IDLEINHIBIT_NONE;
// initial token. Will be unregistered on workspace change or timeout of 2 minutes
std::string m_szInitialWorkspaceToken = "";
std::string m_initialWorkspaceToken = "";
// for groups
struct SGroupData {
@ -300,13 +297,13 @@ class CWindow {
bool head = false;
bool locked = false; // per group lock
bool deny = false; // deny window from enter a group or made a group
} m_sGroupData;
uint16_t m_eGroupRules = GROUP_NONE;
} m_groupData;
uint16_t m_groupRules = GROUP_NONE;
bool m_bTearingHint = false;
bool m_tearingHint = false;
// stores the currently matched window rules
std::vector<SP<CWindowRule>> m_vMatchedRules;
std::vector<SP<CWindowRule>> m_matchedRules;
// window tags
CTagKeeper m_tags;
@ -316,8 +313,8 @@ class CWindow {
// For the list lookup
bool operator==(const CWindow& rhs) const {
return m_pXDGSurface == rhs.m_pXDGSurface && m_pXWaylandSurface == rhs.m_pXWaylandSurface && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize &&
m_bFadingOut == rhs.m_bFadingOut;
return m_xdgSurface == rhs.m_xdgSurface && m_xwaylandSurface == rhs.m_xwaylandSurface && m_position == rhs.m_position && m_size == rhs.m_size &&
m_fadingOut == rhs.m_fadingOut;
}
// methods
@ -411,7 +408,7 @@ class CWindow {
std::optional<std::string> xdgDescription();
CBox getWindowMainSurfaceBox() const {
return {m_vRealPosition->value().x, m_vRealPosition->value().y, m_vRealSize->value().x, m_vRealSize->value().y};
return {m_realPosition->value().x, m_realPosition->value().y, m_realSize->value().x, m_realSize->value().y};
}
// listeners
@ -421,7 +418,7 @@ class CWindow {
std::unordered_map<std::string, std::string> getEnv();
//
PHLWINDOWREF m_pSelf;
PHLWINDOWREF m_self;
// make private once we move listeners to inside CWindow
struct {
@ -436,13 +433,13 @@ class CWindow {
CHyprSignalListener updateState;
CHyprSignalListener updateMetadata;
CHyprSignalListener resourceChange;
} listeners;
} m_listeners;
private:
// For hidden windows and stuff
bool m_bHidden = false;
bool m_bSuspended = false;
WORKSPACEID m_iLastWorkspace = WORKSPACE_INVALID;
bool m_hidden = false;
bool m_suspended = false;
WORKSPACEID m_lastWorkspace = WORKSPACE_INVALID;
};
inline bool valid(PHLWINDOW w) {
@ -456,49 +453,49 @@ inline bool valid(PHLWINDOWREF w) {
inline bool validMapped(PHLWINDOW w) {
if (!valid(w))
return false;
return w->m_bIsMapped;
return w->m_isMapped;
}
inline bool validMapped(PHLWINDOWREF w) {
if (!valid(w))
return false;
return w->m_bIsMapped;
return w->m_isMapped;
}
namespace NWindowProperties {
static const std::unordered_map<std::string, std::function<CWindowOverridableVar<bool>*(const PHLWINDOW&)>> boolWindowProperties = {
{"allowsinput", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.allowsInput; }},
{"dimaround", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.dimAround; }},
{"decorate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.decorate; }},
{"focusonactivate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.focusOnActivate; }},
{"keepaspectratio", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.keepAspectRatio; }},
{"nearestneighbor", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.nearestNeighbor; }},
{"noanim", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noAnim; }},
{"noblur", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noBlur; }},
{"noborder", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noBorder; }},
{"nodim", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noDim; }},
{"nofocus", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noFocus; }},
{"nomaxsize", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noMaxSize; }},
{"norounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noRounding; }},
{"noshadow", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noShadow; }},
{"noshortcutsinhibit", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noShortcutsInhibit; }},
{"opaque", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.opaque; }},
{"forcergbx", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.RGBX; }},
{"syncfullscreen", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.syncFullscreen; }},
{"immediate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.tearing; }},
{"xray", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.xray; }},
{"nofollowmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noFollowMouse; }},
{"allowsinput", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.allowsInput; }},
{"dimaround", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.dimAround; }},
{"decorate", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.decorate; }},
{"focusonactivate", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.focusOnActivate; }},
{"keepaspectratio", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.keepAspectRatio; }},
{"nearestneighbor", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.nearestNeighbor; }},
{"noanim", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noAnim; }},
{"noblur", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noBlur; }},
{"noborder", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noBorder; }},
{"nodim", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noDim; }},
{"nofocus", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noFocus; }},
{"nomaxsize", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noMaxSize; }},
{"norounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noRounding; }},
{"noshadow", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noShadow; }},
{"noshortcutsinhibit", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noShortcutsInhibit; }},
{"opaque", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.opaque; }},
{"forcergbx", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.RGBX; }},
{"syncfullscreen", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.syncFullscreen; }},
{"immediate", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.tearing; }},
{"xray", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.xray; }},
{"nofollowmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.noFollowMouse; }},
};
const std::unordered_map<std::string, std::function<CWindowOverridableVar<Hyprlang::INT>*(const PHLWINDOW&)>> intWindowProperties = {
{"rounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.rounding; }},
{"bordersize", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.borderSize; }},
{"rounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.rounding; }},
{"bordersize", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.borderSize; }},
};
const std::unordered_map<std::string, std::function<CWindowOverridableVar<Hyprlang::FLOAT>*(PHLWINDOW)>> floatWindowProperties = {
{"roundingpower", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.roundingPower; }},
{"scrollmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollMouse; }},
{"scrolltouchpad", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollTouchpad; }},
{"roundingpower", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.roundingPower; }},
{"scrollmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.scrollMouse; }},
{"scrolltouchpad", [](const PHLWINDOW& pWindow) { return &pWindow->m_windowData.scrollTouchpad; }},
};
};
@ -532,13 +529,13 @@ struct std::formatter<PHLWINDOW, CharT> : std::formatter<CharT> {
return std::format_to(out, "[Window nullptr]");
std::format_to(out, "[");
std::format_to(out, "Window {:x}: title: \"{}\"", (uintptr_t)w.get(), w->m_szTitle);
std::format_to(out, "Window {:x}: title: \"{}\"", (uintptr_t)w.get(), w->m_title);
if (formatWorkspace)
std::format_to(out, ", workspace: {}", w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID);
std::format_to(out, ", workspace: {}", w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID);
if (formatMonitor)
std::format_to(out, ", monitor: {}", w->monitorID());
if (formatClass)
std::format_to(out, ", class: {}", w->m_szClass);
std::format_to(out, ", class: {}", w->m_class);
return std::format_to(out, "]");
}
};

View file

@ -13,7 +13,7 @@ static const auto RULES_PREFIX = std::unordered_set<std::string>{
"size", "suppressevent", "tag", "workspace", "xray",
};
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : szValue(value), szRule(rule), v2(isV2), execRule(isExecRule) {
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : m_value(value), m_rule(rule), m_v2(isV2), m_execRule(isExecRule) {
const auto VALS = CVarList(rule, 2, ' ');
const bool VALID = RULES.contains(rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule](auto prefix) { return rule.starts_with(prefix); }) ||
(NWindowProperties::boolWindowProperties.find(VALS[0]) != NWindowProperties::boolWindowProperties.end()) ||
@ -24,73 +24,73 @@ CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool
return;
if (rule == "float")
ruleType = RULE_FLOAT;
m_ruleType = RULE_FLOAT;
else if (rule == "fullscreen")
ruleType = RULE_FULLSCREEN;
m_ruleType = RULE_FULLSCREEN;
else if (rule == "maximize")
ruleType = RULE_MAXIMIZE;
m_ruleType = RULE_MAXIMIZE;
else if (rule == "noinitialfocus")
ruleType = RULE_NOINITIALFOCUS;
m_ruleType = RULE_NOINITIALFOCUS;
else if (rule == "pin")
ruleType = RULE_PIN;
m_ruleType = RULE_PIN;
else if (rule == "stayfocused")
ruleType = RULE_STAYFOCUSED;
m_ruleType = RULE_STAYFOCUSED;
else if (rule == "tile")
ruleType = RULE_TILE;
m_ruleType = RULE_TILE;
else if (rule == "renderunfocused")
ruleType = RULE_RENDERUNFOCUSED;
m_ruleType = RULE_RENDERUNFOCUSED;
else if (rule == "persistentsize")
ruleType = RULE_PERSISTENTSIZE;
m_ruleType = RULE_PERSISTENTSIZE;
else if (rule.starts_with("animation"))
ruleType = RULE_ANIMATION;
m_ruleType = RULE_ANIMATION;
else if (rule.starts_with("bordercolor"))
ruleType = RULE_BORDERCOLOR;
m_ruleType = RULE_BORDERCOLOR;
else if (rule.starts_with("center"))
ruleType = RULE_CENTER;
m_ruleType = RULE_CENTER;
else if (rule.starts_with("fullscreenstate"))
ruleType = RULE_FULLSCREENSTATE;
m_ruleType = RULE_FULLSCREENSTATE;
else if (rule.starts_with("group"))
ruleType = RULE_GROUP;
m_ruleType = RULE_GROUP;
else if (rule.starts_with("idleinhibit"))
ruleType = RULE_IDLEINHIBIT;
m_ruleType = RULE_IDLEINHIBIT;
else if (rule.starts_with("maxsize"))
ruleType = RULE_MAXSIZE;
m_ruleType = RULE_MAXSIZE;
else if (rule.starts_with("minsize"))
ruleType = RULE_MINSIZE;
m_ruleType = RULE_MINSIZE;
else if (rule.starts_with("monitor"))
ruleType = RULE_MONITOR;
m_ruleType = RULE_MONITOR;
else if (rule.starts_with("move"))
ruleType = RULE_MOVE;
m_ruleType = RULE_MOVE;
else if (rule.starts_with("opacity"))
ruleType = RULE_OPACITY;
m_ruleType = RULE_OPACITY;
else if (rule.starts_with("plugin:"))
ruleType = RULE_PLUGIN;
m_ruleType = RULE_PLUGIN;
else if (rule.starts_with("pseudo"))
ruleType = RULE_PSEUDO;
m_ruleType = RULE_PSEUDO;
else if (rule.starts_with("size"))
ruleType = RULE_SIZE;
m_ruleType = RULE_SIZE;
else if (rule.starts_with("suppressevent"))
ruleType = RULE_SUPPRESSEVENT;
m_ruleType = RULE_SUPPRESSEVENT;
else if (rule.starts_with("tag"))
ruleType = RULE_TAG;
m_ruleType = RULE_TAG;
else if (rule.starts_with("workspace"))
ruleType = RULE_WORKSPACE;
m_ruleType = RULE_WORKSPACE;
else if (rule.starts_with("prop"))
ruleType = RULE_PROP;
m_ruleType = RULE_PROP;
else if (rule.starts_with("content"))
ruleType = RULE_CONTENT;
m_ruleType = RULE_CONTENT;
else {
// check if this is a prop.
const CVarList VARS(rule, 0, 's', true);
if (NWindowProperties::intWindowProperties.find(VARS[0]) != NWindowProperties::intWindowProperties.end() ||
NWindowProperties::boolWindowProperties.find(VARS[0]) != NWindowProperties::boolWindowProperties.end() ||
NWindowProperties::floatWindowProperties.find(VARS[0]) != NWindowProperties::floatWindowProperties.end()) {
*const_cast<std::string*>(&szRule) = "prop " + rule;
ruleType = RULE_PROP;
Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, szRule);
*const_cast<std::string*>(&m_rule) = "prop " + rule;
m_ruleType = RULE_PROP;
Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, m_rule);
} else {
Debug::log(ERR, "CWindowRule: didn't match a rule that was found valid?!");
ruleType = RULE_INVALID;
m_ruleType = RULE_INVALID;
}
}
}

View file

@ -40,33 +40,33 @@ class CWindowRule {
RULE_PERSISTENTSIZE
};
eRuleType ruleType = RULE_INVALID;
eRuleType m_ruleType = RULE_INVALID;
const std::string szValue;
const std::string szRule;
const bool v2 = false;
const bool execRule = false;
const std::string m_value;
const std::string m_rule;
const bool m_v2 = false;
const bool m_execRule = false;
std::string szTitle;
std::string szClass;
std::string szInitialTitle;
std::string szInitialClass;
std::string szTag;
int bX11 = -1; // -1 means "ANY"
int bFloating = -1;
int bFullscreen = -1;
int bPinned = -1;
int bFocus = -1;
std::string szFullscreenState = ""; // empty means any
std::string szOnWorkspace = ""; // empty means any
std::string szWorkspace = ""; // empty means any
std::string szContentType = ""; // empty means any
std::string szXdgTag = ""; // empty means any
std::string m_title;
std::string m_class;
std::string m_initialTitle;
std::string m_initialClass;
std::string m_tag;
int m_X11 = -1; // -1 means "ANY"
int m_floating = -1;
int m_fullscreen = -1;
int m_pinned = -1;
int m_focus = -1;
std::string m_fullscreenState = ""; // empty means any
std::string m_onWorkspace = ""; // empty means any
std::string m_workspace = ""; // empty means any
std::string m_contentType = ""; // empty means any
std::string m_xdgTag = ""; // empty means any
// precompiled regexes
CRuleRegexContainer rTitle;
CRuleRegexContainer rClass;
CRuleRegexContainer rInitialTitle;
CRuleRegexContainer rInitialClass;
CRuleRegexContainer rV1Regex;
CRuleRegexContainer m_titleRegex;
CRuleRegexContainer m_classRegex;
CRuleRegexContainer m_initialTitleRegex;
CRuleRegexContainer m_initialClassRegex;
CRuleRegexContainer m_v1Regex;
};

View file

@ -525,7 +525,7 @@ MONITORID CWorkspace::monitorID() {
PHLWINDOW CWorkspace::getFullscreenWindow() {
for (auto const& w : g_pCompositor->m_windows) {
if (w->m_pWorkspace == m_self && w->isFullscreen())
if (w->m_workspace == m_self && w->isFullscreen())
return w;
}
@ -547,11 +547,11 @@ bool CWorkspace::isVisibleNotCovered() {
int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> onlyVisible) {
int no = 0;
for (auto const& w : g_pCompositor->m_windows) {
if (w->workspaceID() != m_id || !w->m_bIsMapped)
if (w->workspaceID() != m_id || !w->m_isMapped)
continue;
if (onlyTiled.has_value() && w->m_bIsFloating == onlyTiled.value())
if (onlyTiled.has_value() && w->m_isFloating == onlyTiled.value())
continue;
if (onlyPinned.has_value() && w->m_bPinned != onlyPinned.value())
if (onlyPinned.has_value() && w->m_pinned != onlyPinned.value())
continue;
if (onlyVisible.has_value() && w->isHidden() == onlyVisible.value())
continue;
@ -564,13 +564,13 @@ int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> on
int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> onlyVisible) {
int no = 0;
for (auto const& w : g_pCompositor->m_windows) {
if (w->workspaceID() != m_id || !w->m_bIsMapped)
if (w->workspaceID() != m_id || !w->m_isMapped)
continue;
if (!w->m_sGroupData.head)
if (!w->m_groupData.head)
continue;
if (onlyTiled.has_value() && w->m_bIsFloating == onlyTiled.value())
if (onlyTiled.has_value() && w->m_isFloating == onlyTiled.value())
continue;
if (onlyPinned.has_value() && w->m_bPinned != onlyPinned.value())
if (onlyPinned.has_value() && w->m_pinned != onlyPinned.value())
continue;
if (onlyVisible.has_value() && w->isHidden() == onlyVisible.value())
continue;
@ -581,7 +581,7 @@ int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onl
PHLWINDOW CWorkspace::getFirstWindow() {
for (auto const& w : g_pCompositor->m_windows) {
if (w->m_pWorkspace == m_self && w->m_bIsMapped && !w->isHidden())
if (w->m_workspace == m_self && w->m_isMapped && !w->isHidden())
return w;
}
@ -592,7 +592,7 @@ PHLWINDOW CWorkspace::getTopLeftWindow() {
const auto PMONITOR = m_monitor.lock();
for (auto const& w : g_pCompositor->m_windows) {
if (w->m_pWorkspace != m_self || !w->m_bIsMapped || w->isHidden())
if (w->m_workspace != m_self || !w->m_isMapped || w->isHidden())
continue;
const auto WINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved();
@ -605,7 +605,7 @@ PHLWINDOW CWorkspace::getTopLeftWindow() {
bool CWorkspace::hasUrgentWindow() {
for (auto const& w : g_pCompositor->m_windows) {
if (w->m_pWorkspace == m_self && w->m_bIsMapped && w->m_bIsUrgent)
if (w->m_workspace == m_self && w->m_isMapped && w->m_isUrgent)
return true;
}
@ -614,7 +614,7 @@ bool CWorkspace::hasUrgentWindow() {
void CWorkspace::updateWindowDecos() {
for (auto const& w : g_pCompositor->m_windows) {
if (w->m_pWorkspace != m_self)
if (w->m_workspace != m_self)
continue;
w->updateWindowDecos();
@ -625,7 +625,7 @@ void CWorkspace::updateWindowData() {
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_self.lock());
for (auto const& w : g_pCompositor->m_windows) {
if (w->m_pWorkspace != m_self)
if (w->m_workspace != m_self)
continue;
w->updateWindowData(WORKSPACERULE);
@ -634,7 +634,7 @@ void CWorkspace::updateWindowData() {
void CWorkspace::forceReportSizesToWindows() {
for (auto const& w : g_pCompositor->m_windows) {
if (w->m_pWorkspace != m_self || !w->m_bIsMapped || w->isHidden())
if (w->m_workspace != m_self || !w->m_isMapped || w->isHidden())
continue;
w->sendWindowSize(true);
@ -658,10 +658,10 @@ void CWorkspace::rename(const std::string& name) {
}
void CWorkspace::updateWindows() {
m_hasFullscreenWindow = std::ranges::any_of(g_pCompositor->m_windows, [this](const auto& w) { return w->m_bIsMapped && w->m_pWorkspace == m_self && w->isFullscreen(); });
m_hasFullscreenWindow = std::ranges::any_of(g_pCompositor->m_windows, [this](const auto& w) { return w->m_isMapped && w->m_workspace == m_self && w->isFullscreen(); });
for (auto const& w : g_pCompositor->m_windows) {
if (!w->m_bIsMapped || w->m_pWorkspace != m_self)
if (!w->m_isMapped || w->m_workspace != m_self)
continue;
w->updateDynamicRules();