void CreateNodeContainer(screen_info *Screen, tree_node *Node, int ContainerType) { if(Node->SplitRatio == 0) Node->SplitRatio = KWMScreen.SplitRatio; switch(ContainerType) { case 1: { Node->Container = LeftVerticalContainerSplit(Screen, Node->Parent); } break; case 2: { Node->Container = RightVerticalContainerSplit(Screen, Node->Parent); } break; case 3: { Node->Container = UpperHorizontalContainerSplit(Screen, Node->Parent); } break; case 4: { Node->Container = LowerHorizontalContainerSplit(Screen, Node->Parent); } break; } Node->SplitMode = GetOptimalSplitMode(Node); Node->Container.Type = ContainerType; }
void SetRootNodeContainer(screen_info *Screen, tree_node *Node) { space_info *Space = &Screen->Space[Screen->ActiveSpace]; Node->Container.X = Screen->X + Space->Offset.PaddingLeft; Node->Container.Y = Screen->Y + Space->Offset.PaddingTop; Node->Container.Width = Screen->Width - Space->Offset.PaddingLeft - Space->Offset.PaddingRight; Node->Container.Height = Screen->Height - Space->Offset.PaddingTop - Space->Offset.PaddingBottom; Node->SplitMode = GetOptimalSplitMode(Node); Node->Container.Type = 0; }
void CreatePseudoNode() { ax_display *Display = AXLibMainDisplay(); space_info *SpaceInfo = &WindowTree[Display->Space->Identifier]; if(!FocusedApplication) return; ax_window *Window = FocusedApplication->Focus; if(!Window) return; tree_node *Node = GetTreeNodeFromWindowID(SpaceInfo->RootNode, Window->ID); if(Node) { split_type SplitMode = KWMSettings.SplitMode == SPLIT_OPTIMAL ? GetOptimalSplitMode(Node) : KWMSettings.SplitMode; CreateLeafNodePair(Display, Node, Node->WindowID, 0, SplitMode); ApplyTreeNodeContainer(Node); } }
bool CreateBSPTree(tree_node *RootNode, screen_info *Screen, std::vector<window_info*> *WindowsPtr) { bool Result = false; std::vector<window_info*> &Windows = *WindowsPtr; if(Windows.size() >= 2) { tree_node *Root = RootNode; std::size_t FirstIndex; bool FoundValidWindow = false; for(FirstIndex = 0; FirstIndex < Windows.size(); ++FirstIndex) { if(!IsWindowFloating(Windows[FirstIndex]->WID, NULL)) { Root->WindowID = Windows[FirstIndex]->WID; FoundValidWindow = true; break; } } if(!FoundValidWindow) return false; for(std::size_t WindowIndex = FirstIndex + 1; WindowIndex < Windows.size(); ++WindowIndex) { if(!IsWindowFloating(Windows[WindowIndex]->WID, NULL)) { while(!IsLeafNode(Root)) { if(!IsLeafNode(Root->LeftChild) && IsLeafNode(Root->RightChild)) Root = Root->RightChild; else Root = Root->LeftChild; } DEBUG("CreateBSPTree() Create pair of leafs") CreateLeafNodePair(Screen, Root, Root->WindowID, Windows[WindowIndex]->WID, GetOptimalSplitMode(Root)); Root = RootNode; } } Result = true; } else if(Windows.size() == 1 && !IsWindowFloating(Windows[0]->WID, NULL)) { RootNode->WindowID = Windows[0]->WID; Result = true; } return Result; }
void FillDeserializedTree(tree_node *RootNode) { std::vector<window_info*> Windows = GetAllWindowsOnDisplay(KWMScreen.Current->ID); tree_node *Current = NULL; GetFirstLeafNode(RootNode, (void**)&Current); std::size_t Counter = 0, Leafs = 0; while(Current) { if(Counter < Windows.size()) Current->WindowID = Windows[Counter++]->WID; Current = GetNearestTreeNodeToTheRight(Current); ++Leafs; } if(Leafs < Windows.size() && Counter < Windows.size()) { tree_node *Root = RootNode; for(; Counter < Windows.size(); ++Counter) { while(!IsLeafNode(Root)) { if(!IsLeafNode(Root->LeftChild) && IsLeafNode(Root->RightChild)) Root = Root->RightChild; else Root = Root->LeftChild; } DEBUG("FillDeserializedTree() Create pair of leafs"); CreateLeafNodePair(KWMScreen.Current, Root, Root->WindowID, Windows[Counter]->WID, GetOptimalSplitMode(Root)); Root = RootNode; } } }
bool CreateBSPTree(tree_node *RootNode, screen_info *Screen, std::vector<window_info*> *WindowsPtr) { Assert(RootNode); bool Result = false; std::vector<window_info*> &Windows = *WindowsPtr; if(!Windows.empty()) { tree_node *Root = RootNode; Root->WindowID = Windows[0]->WID; for(std::size_t WindowIndex = 1; WindowIndex < Windows.size(); ++WindowIndex) { while(!IsLeafNode(Root)) { if(!IsLeafNode(Root->LeftChild) && IsLeafNode(Root->RightChild)) Root = Root->RightChild; else Root = Root->LeftChild; } DEBUG("CreateBSPTree() Create pair of leafs"); CreateLeafNodePair(Screen, Root, Root->WindowID, Windows[WindowIndex]->WID, GetOptimalSplitMode(Root)); Root = RootNode; } Result = true; } return Result; }