void ModifyContainerSplitRatio(double Offset) { if(!FocusedApplication) return; ax_window *Window = FocusedApplication->Focus; if(!Window) return; ax_display *Display = AXLibWindowDisplay(Window); space_info *SpaceInfo = &WindowTree[Display->Space->Identifier]; tree_node *Root = SpaceInfo->RootNode; if(!Root || IsLeafNode(Root) || Root->WindowID != 0) return; tree_node *Node = GetTreeNodeFromWindowIDOrLinkNode(Root, Window->ID); if(Node && Node->Parent) { if(Node->Parent->SplitRatio + Offset > 0.0 && Node->Parent->SplitRatio + Offset < 1.0) { Node->Parent->SplitRatio += Offset; ResizeNodeContainer(Display, Node->Parent); ApplyTreeNodeContainer(Node->Parent); } } }
void ChangeTypeOfFocusedNode(node_type Type) { ax_window *Window = FocusedApplication ? FocusedApplication->Focus : NULL; if(!Window) return; ax_display *Display = AXLibWindowDisplay(Window); space_info *SpaceInfo = &WindowTree[Display->Space->Identifier]; tree_node *TreeNode = GetTreeNodeFromWindowIDOrLinkNode(SpaceInfo->RootNode, Window->ID); if(TreeNode && TreeNode != SpaceInfo->RootNode) TreeNode->Type = Type; }
void ModifyContainerSplitRatio(double Offset, int Degrees) { if(!FocusedApplication) return; ax_window *Window = FocusedApplication->Focus; if(!Window) return; ax_display *Display = AXLibWindowDisplay(Window); space_info *SpaceInfo = &WindowTree[Display->Space->Identifier]; tree_node *Root = SpaceInfo->RootNode; if(!Root || IsLeafNode(Root) || Root->WindowID != 0) return; tree_node *Node = GetTreeNodeFromWindowIDOrLinkNode(Root, Window->ID); if(Node) { ax_window *ClosestWindow = NULL; if(FindClosestWindow(Degrees, &ClosestWindow, false)) { tree_node *Target = GetTreeNodeFromWindowIDOrLinkNode(Root, ClosestWindow->ID); tree_node *Ancestor = FindLowestCommonAncestor(Node, Target); if(Ancestor) { if(!(Node == Ancestor->LeftChild || IsLeftChildInSubTree(Ancestor->LeftChild, Node))) Offset = -Offset; double NewSplitRatio = Ancestor->SplitRatio + Offset; SetContainerSplitRatio(NewSplitRatio, Node, Ancestor, Display, true); } } } }
internal std::string GetSplitModeOfWindow(ax_window *Window) { std::string Output; if(!Window) return ""; ax_display *Display = AXLibWindowDisplay(Window); space_info *SpaceInfo = &WindowTree[Display->Space->Identifier]; tree_node *Node = GetTreeNodeFromWindowIDOrLinkNode(SpaceInfo->RootNode, Window->ID); if(Node) { if(Node->SplitMode == SPLIT_VERTICAL) Output = "Vertical"; else if(Node->SplitMode == SPLIT_HORIZONTAL) Output = "Horizontal"; } return Output; }