YggdrasilWM
0.1.1
A tiny window manager coded in C++
|
TreeLayoutManager class this class is a subclass of LayoutManager it handles the tree style layout When a client is added, it looks recursively for the biggest space and splits it in two placing the new client in the left space and the old client in the right space. More...
#include <TreeLayoutManager.hpp>
Public Member Functions | |
TreeLayoutManager (Display *display, Window root, int sizeX, int sizeY, int posX, int posY, int borderSize, int gap, int barHeight) | |
Construct a new Tree Layout Manager object the size and position of the root space should take account of the bar size and position and the border size. More... | |
~TreeLayoutManager () override | |
Destroy the Tree Layout Manager object. More... | |
void | updateGeometry (unsigned int sizeX, unsigned int sizeY, unsigned int posX, unsigned int posY) override |
update the geometry of the layout (resize) More... | |
void | reSize (const Point &size, const Point &pos) override |
void | recursiveResize (const Point &size, const Point &pos, BinarySpace *space) |
BinarySpace * | findSpace (Client *client) |
find the space containing the client it looks recursively for the space containing the client More... | |
BinarySpace * | findSpaceRecursive (Client *client, BinarySpace *space) |
recursive method to find the space containing the client More... | |
BinarySpace * | findSpace (int index) |
void | addClient (std::shared_ptr< Client > client) override |
add a client to the layout it looks for the biggest space and splits it in two More... | |
void | addClientRecursive (std::shared_ptr< Client > client, BinarySpace *space) |
void | placeClientInSpace (const std::shared_ptr< Client > &client, BinarySpace *space) |
place a client in a space moves and resizes the client window to fit the space restack the client window More... | |
void | splitSpace (const std::shared_ptr< Client > &client, BinarySpace *space, bool splitAlongX) |
split a space in two Move the client to the left space and the old client to the right space increase the subspaces counter of all the parent spaces More... | |
void | removeClient (Client *client) override |
remove a client from the layout use the recursive method to remove the client More... | |
void | removeClientRecursive (Client *client, BinarySpace *space) |
recursive method to add a client to the layout More... | |
void | growSpace (Client *client, int inc) |
grow the space of the client in the x axis More... | |
void | recursiveShrinkSiblingSpace (BinarySpace *space, int inc, bool vertical) |
Protected Attributes | |
int | screen_width_ |
int | screen_height_ |
int | gap_ |
int | border_size_ |
int | space_count_ |
Display * | display_ |
Window | rootWindow_ |
Private Member Functions | |
void | deleteSpace (BinarySpace *space) |
Private Attributes | |
std::unique_ptr< BinarySpace > | rootSpace_ |
TreeLayoutManager class this class is a subclass of LayoutManager it handles the tree style layout When a client is added, it looks recursively for the biggest space and splits it in two placing the new client in the left space and the old client in the right space.
TreeLayoutManager::TreeLayoutManager | ( | Display * | display, |
Window | root, | ||
int | sizeX, | ||
int | sizeY, | ||
int | posX, | ||
int | posY, | ||
int | borderSize, | ||
int | gap, | ||
int | barHeight | ||
) |
Construct a new Tree Layout Manager object the size and position of the root space should take account of the bar size and position and the border size.
display | |
root | |
sizeX | |
sizeY | |
posX | |
posY | |
borderSize | |
gap | |
barHeight |
References rootSpace_.
|
overridevirtual |
add a client to the layout it looks for the biggest space and splits it in two
client |
Implements LayoutManager.
References addClientRecursive(), and rootSpace_.
void TreeLayoutManager::addClientRecursive | ( | std::shared_ptr< Client > | client, |
BinarySpace * | space | ||
) |
References BinarySpace::getClient(), BinarySpace::getLeft(), BinarySpace::getRight(), BinarySpace::getSize(), placeClientInSpace(), splitSpace(), Point::x, and Point::y.
Referenced by addClient().
|
private |
References BinarySpace::getLeft(), and BinarySpace::getRight().
BinarySpace * TreeLayoutManager::findSpace | ( | Client * | client | ) |
find the space containing the client it looks recursively for the space containing the client
client |
References findSpaceRecursive(), and rootSpace_.
Referenced by growSpace().
BinarySpace * TreeLayoutManager::findSpace | ( | int | index | ) |
BinarySpace * TreeLayoutManager::findSpaceRecursive | ( | Client * | client, |
BinarySpace * | space | ||
) |
recursive method to find the space containing the client
client | |
space |
References BinarySpace::getClient(), BinarySpace::getLeft(), and BinarySpace::getRight().
Referenced by findSpace().
void TreeLayoutManager::growSpace | ( | Client * | client, |
int | inc | ||
) |
grow the space of the client in the x axis
client |
References findSpace(), BinarySpace::getClient(), BinarySpace::getLeft(), BinarySpace::getParent(), BinarySpace::getPos(), BinarySpace::getRight(), BinarySpace::getSize(), placeClientInSpace(), recursiveShrinkSiblingSpace(), rootSpace_, BinarySpace::setPos(), BinarySpace::setSize(), Point::x, and Point::y.
Referenced by Grow::execute().
void TreeLayoutManager::placeClientInSpace | ( | const std::shared_ptr< Client > & | client, |
BinarySpace * | space | ||
) |
place a client in a space moves and resizes the client window to fit the space restack the client window
client | |
space |
References LayoutManager::border_size_, LayoutManager::gap_, BinarySpace::getClient(), BinarySpace::getPos(), BinarySpace::getSize(), BinarySpace::setClient(), Point::x, and Point::y.
Referenced by addClientRecursive(), growSpace(), recursiveResize(), recursiveShrinkSiblingSpace(), removeClientRecursive(), and splitSpace().
void TreeLayoutManager::recursiveResize | ( | const Point & | size, |
const Point & | pos, | ||
BinarySpace * | space | ||
) |
References BinarySpace::getClient(), BinarySpace::getLeft(), BinarySpace::getRight(), BinarySpace::getSize(), placeClientInSpace(), BinarySpace::setPos(), BinarySpace::setSize(), Point::x, and Point::y.
Referenced by reSize().
void TreeLayoutManager::recursiveShrinkSiblingSpace | ( | BinarySpace * | space, |
int | inc, | ||
bool | vertical | ||
) |
References BinarySpace::getClient(), BinarySpace::getLeft(), BinarySpace::getRight(), BinarySpace::getSize(), placeClientInSpace(), BinarySpace::setSize(), Point::x, and Point::y.
Referenced by growSpace().
|
overridevirtual |
remove a client from the layout use the recursive method to remove the client
client |
Implements LayoutManager.
References removeClientRecursive(), and rootSpace_.
void TreeLayoutManager::removeClientRecursive | ( | Client * | client, |
BinarySpace * | space | ||
) |
recursive method to add a client to the layout
recursive method to remove a client from the layout
client | |
space |
References BinarySpace::getClient(), BinarySpace::getLeft(), BinarySpace::getParent(), BinarySpace::getRight(), placeClientInSpace(), rootSpace_, BinarySpace::setClient(), BinarySpace::setLeft(), and BinarySpace::setRight().
Referenced by removeClient().
Implements LayoutManager.
References recursiveResize(), rootSpace_, Point::x, and Point::y.
Referenced by updateGeometry().
void TreeLayoutManager::splitSpace | ( | const std::shared_ptr< Client > & | client, |
BinarySpace * | space, | ||
bool | splitAlongX | ||
) |
split a space in two Move the client to the left space and the old client to the right space increase the subspaces counter of all the parent spaces
client | |
space | |
splitAlongX |
References BinarySpace::getClient(), BinarySpace::getParent(), BinarySpace::getPos(), BinarySpace::getSize(), BinarySpace::incSubSpaceCount(), placeClientInSpace(), BinarySpace::setClient(), BinarySpace::setLeft(), BinarySpace::setRight(), LayoutManager::space_count_, Point::x, and Point::y.
Referenced by addClientRecursive().
|
overridevirtual |
update the geometry of the layout (resize)
Implements LayoutManager.
References reSize().
|
protectedinherited |
Referenced by placeClientInSpace().
|
protectedinherited |
|
protectedinherited |
Referenced by placeClientInSpace().
|
private |
Referenced by addClient(), findSpace(), growSpace(), removeClient(), removeClientRecursive(), reSize(), and TreeLayoutManager().
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
Referenced by splitSpace().