From 723870337f299d4c80aa0048144f3a1ca1c885bd Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sat, 21 Feb 2026 21:30:39 +0000 Subject: layout: rethonk layouts from the ground up (#12890) Rewrites layouts to be much smaller, and deal with much less annoying BS. Improves the overall architecture, unifies handling of pseudotiling, and various other improvements. --- src/desktop/view/Window.hpp | 56 +++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 32 deletions(-) (limited to 'src/desktop/view/Window.hpp') diff --git a/src/desktop/view/Window.hpp b/src/desktop/view/Window.hpp index 38e8ef0b..a986a63b 100644 --- a/src/desktop/view/Window.hpp +++ b/src/desktop/view/Window.hpp @@ -26,8 +26,19 @@ struct SWorkspaceRule; class IWindowTransformer; +namespace Layout { + class ITarget; + class CWindowTarget; +} + +namespace Desktop { + enum eFocusReason : uint8_t; +} + namespace Desktop::View { + class CGroup; + enum eGroupRules : uint8_t { // effective only during first map, except for _ALWAYS variant GROUP_NONE = 0, @@ -38,6 +49,7 @@ namespace Desktop::View { GROUP_LOCK_ALWAYS = 1 << 4, GROUP_INVADE = 1 << 5, // Force enter a group, event if lock is engaged GROUP_OVERRIDE = 1 << 6, // Override other rules + GROUP_DENY = 1 << 7, // deny }; enum eGetWindowProperties : uint8_t { @@ -61,6 +73,11 @@ namespace Desktop::View { SUPPRESS_FULLSCREEN_OUTPUT = 1 << 4, }; + struct SWindowActiveEvent { + PHLWINDOW window = nullptr; + eFocusReason reason = sc(0) /* unknown */; + }; + struct SInitialWorkspaceToken { PHLWINDOWREF primaryOwner; std::string workspace; @@ -97,6 +114,8 @@ namespace Desktop::View { WP m_xdgSurface; WP m_xwaylandSurface; + SP m_target; + // this is the position and size of the "bounding box" Vector2D m_position = Vector2D(0, 0); Vector2D m_size = Vector2D(0, 0); @@ -112,23 +131,14 @@ namespace Desktop::View { std::optional> m_pendingSizeAck; std::vector> m_pendingSizeAcks; - // for restoring floating statuses - Vector2D m_lastFloatingSize; - Vector2D m_lastFloatingPosition; - // for floating window offset in workspace animations Vector2D m_floatingOffset = Vector2D(0, 0); - // this is used for pseudotiling - bool m_isPseudotiled = false; - Vector2D m_pseudoSize = Vector2D(1280, 720); - // for recovering relative cursor position Vector2D m_relativeCursorCoordsOnLastWarp = Vector2D(-1, -1); 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 = ""; @@ -229,15 +239,10 @@ namespace Desktop::View { std::string m_initialWorkspaceToken = ""; // for groups - struct SGroupData { - PHLWINDOWREF pNextWindow; // nullptr means no grouping. Self means single group. - bool head = false; - bool locked = false; // per group lock - bool deny = false; // deny window from enter a group or made a group - } m_groupData; - uint16_t m_groupRules = Desktop::View::GROUP_NONE; + SP m_group; + uint16_t m_groupRules = Desktop::View::GROUP_NONE; - bool m_tearingHint = false; + bool m_tearingHint = false; // Stable ID for ext_foreign_toplevel_list const uint64_t m_stableID = 0x2137; @@ -303,21 +308,6 @@ namespace Desktop::View { bool isInCurvedCorner(double x, double y); bool hasPopupAt(const Vector2D& pos); int popupsCount(); - void applyGroupRules(); - void createGroup(); - void destroyGroup(); - PHLWINDOW getGroupHead(); - PHLWINDOW getGroupTail(); - PHLWINDOW getGroupCurrent(); - PHLWINDOW getGroupPrevious(); - PHLWINDOW getGroupWindowByIndex(int); - bool hasInGroup(PHLWINDOW); - int getGroupSize(); - bool canBeGroupedInto(PHLWINDOW pWindow); - void setGroupCurrent(PHLWINDOW pWindow); - void insertWindowToGroup(PHLWINDOW pWindow); - void updateGroupOutputs(); - void switchWithWindowInGroup(PHLWINDOW pWindow); void setAnimationsToMove(); void onWorkspaceAnimUpdate(); void onFocusAnimUpdate(); @@ -350,6 +340,8 @@ namespace Desktop::View { std::optional calculateExpression(const std::string& s); std::optional minSize(); std::optional maxSize(); + SP layoutTarget(); + bool canBeGroupedInto(SP group); CBox getWindowMainSurfaceBox() const { return {m_realPosition->value().x, m_realPosition->value().y, m_realSize->value().x, m_realSize->value().y}; -- cgit v1.2.3