1. Micah Nordland
  2. Mirror

Commits

Micah Nordland  committed 31742c0

Window division now works, it's not quite right yet, but I'm not going to worry about
that now. vim style modes are comming next.

  • Participants
  • Parent commits cd50a43
  • Branches default

Comments (0)

Files changed (3)

File include/boxTree.h

View file
     public:
         BoxTree();
         ~BoxTree();
-        void insert(Box* box);
+        void insert(Box* box, bool verticalSplit);
         void rotate(Box *pivot, Rotate rot);
 		void remove(Box *box);
 		void destroy(Box *box);

File src/boxTree.cpp

View file
  *it in its entirety. The original source can be 
  *found here:
  *https://github.com/baskerville/bspwm/
- *Oh, the printTree(), and destroy()
+ *Oh, the printTree(), layoutBoxes(), and destroy()
  *methods are mine, and I tweaked the 
  *insert() method  a bit.
  */
     destroy(root);
 }
 
-void BoxTree::insert(Box *box)
+void BoxTree::insert(Box *box, bool verticalSplit)
 {
     std::cout << "inserting new box" << std::endl;
     if(not focused)
             dad->first = box;
             dad->second = focused;
             focused->parent = dad;
+            if (verticalSplit)
+                dad->splitType = Vertical;
+            else
+                dad->splitType = Horizontal;
             root = dad;
         }
         else
     {
         box->window->setGeometry(area);
     }
-    xcb_rectangle_t rect;
-    rect.x = area.x;
-    rect.y = area.y;
-    rect.width = area.width/2;
-    rect.height = area.height;
-    layoutBoxes(box->first, rect);
-    rect.x += rect.width;
-    layoutBoxes(box->second, rect);
+    xcb_rectangle_t rect1;
+    xcb_rectangle_t rect2;
+    rect1.x = area.x;
+    rect1.y = area.y;
+    if (box->splitType == Vertical)
+    {    
+        rect1.width = area.width * box->splitRatio;
+        rect1.height = area.height;
+        rect2 = rect1;
+        rect2.x += rect2.width;
+    }
+    else
+    {
+    
+        rect1.width = area.width; 
+        rect1.height = area.height * box->splitRatio;
+        rect2 = rect1;
+        rect2.y += rect2.height;
+    }
+    layoutBoxes(box->first, rect1);
+    layoutBoxes(box->second, rect2);
     
     
 }

File src/eventHandlers.cpp

View file
     box->window = window;
     box->value = std::to_string(boxUid++);
     BoxTree &tree = setup->monitors[0].tagList[0].boxTree;
-    tree.insert(box);
+    tree.insert(box, (setup->monitors[0].area.width > setup->monitors[0].area.height));
     tree.layoutBoxes(tree.getRoot(), setup->monitors[0].area);
     xcb_map_window(setup->conn, ev->window);
     tree.printTree(tree.getRoot());