Skip to content

Commit

Permalink
Started implementing MasterLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
corecaps committed Mar 21, 2024
1 parent 1b5bd7f commit 4cffe71
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 24 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ set(SOURCES
${SOURCE_DIR}/Layouts/LayoutManager.cpp
${INCLUDE_DIR}/Layouts/LayoutManager.hpp
${SOURCE_DIR}/Layouts/TreeLayoutManager.cpp
${SOURCE_DIR}/Layouts/MasterLayoutManager.cpp
${SOURCE_DIR}/Layouts/MasterSpace.cpp
${SOURCE_DIR}/Layouts/BinarySpace.cpp
${SOURCE_DIR}/Config/ConfigHandler.cpp
${INCLUDE_DIR}/Config/ConfigDataBase.hpp
Expand Down
6 changes: 3 additions & 3 deletions inc/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
* @file Group.hpp
* @brief Group class header.
* @date 2024-02-12
* @date 2024-03-21
*
*/

Expand All @@ -46,8 +46,8 @@ class BaseX11Wrapper;
enum LayoutType {
TREE,
MAX,
VERTICAL,
HORIZONTAL,
MASTER_VERTICAL,
MASTER_HORIZONTAL,
FLOAT
};
/**
Expand Down
50 changes: 50 additions & 0 deletions inc/Layouts/MasterLayoutManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Yb dP 8 w 8 Yb dP 8b d8
* YbdP .d88 .d88 .d88 8d8b .d88 d88b w 8 Yb db dP 8YbmdP8
* YP 8 8 8 8 8 8 8P 8 8 `Yb. 8 8 YbdPYbdP 8 " 8
* 88 `Y88 `Y88 `Y88 8 `Y88 Y88P 8 8 YP YP 8 8
* wwdP wwdP
* Yggdrasil Window Manager
* https://github.com/corecaps/YggdrasilWM
* Copyright (C) 2024 jgarcia <[email protected]> <[email protected]>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
* @file MasterLayoutManager.hpp
* @brief handle Master Style Layout.
* @date 2024-03-21
*/
#ifndef YGGDRASILWM_MASTERLAYOUTMANAGER_HPP
#define YGGDRASILWM_MASTERLAYOUTMANAGER_HPP
#include "Layouts/LayoutManager.hpp"
class MasterSpace;
class MasterLayoutManager : public LayoutManager {
MasterLayoutManager(Display* display,
Window root,
int sizeX,
int sizeY,
int posX,
int posY,
int borderSize,
int gap,
int barHeight);
~MasterLayoutManager() override = default;
void updateGeometry(unsigned int sizeX, unsigned int sizeY, unsigned int posX, unsigned int posY) override;
void reSize(const Point &size,const Point &pos) override;
void addClient(std::shared_ptr<Client> client) override;
void removeClient(Client *client) override;
private:
std::unique_ptr<MasterSpace> rootSpace_;
};

#endif // YGGDRASILWM_MASTERLAYOUTMANAGER_HPP
76 changes: 76 additions & 0 deletions inc/Layouts/MasterSpace.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* Yb dP 8 w 8 Yb dP 8b d8
* YbdP .d88 .d88 .d88 8d8b .d88 d88b w 8 Yb db dP 8YbmdP8
* YP 8 8 8 8 8 8 8P 8 8 `Yb. 8 8 YbdPYbdP 8 " 8
* 88 `Y88 `Y88 `Y88 8 `Y88 Y88P 8 8 YP YP 8 8
* wwdP wwdP
* Yggdrasil Window Manager
* https://github.com/corecaps/YggdrasilWM
* Copyright (C) 2024 jgarcia <[email protected]> <[email protected]>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
* @file MasterSpace.hpp
* @brief MasterSpace class header.
* @date 2024-03-21
*/

#ifndef YGGDRASILWM_MASTERSPACE_HPP
#define YGGDRASILWM_MASTERSPACE_HPP
#include "Layouts/Point.hpp"
#include <memory>
#include <vector>
class Client;
class MasterSpace {
public:
MasterSpace(Point pos,
Point size,
int index,
bool master,
bool vertical,
MasterSpace* parent = nullptr);
~MasterSpace();
const Point &getPos() const;
void setPos(const Point &pos);
const Point &getSize() const;
void setSize(const Point &size);
bool isMaster() const;
void setIsMaster(bool isMaster);
bool isVertical() const;
void setIsVertical(bool isVertical);
int getIndex() const;
void setIndex(int index);
int getSubspaceCount() const;
void setSubspaceCount(int subspaceCount);
MasterSpace *getParent() const;
void setParent(MasterSpace *parent);
MasterSpace *getMaster() const;
void setMaster(std::unique_ptr<MasterSpace>master);
const std::vector<std::unique_ptr<MasterSpace>> &getSlaves() const;
const std::weak_ptr<Client> &getClient() const;

void setClient(const std::weak_ptr<Client> &client);

private:
Point pos_;
Point size_;
bool is_master_;
bool is_vertical_;
int index_;
int subspace_count_;
MasterSpace* parent_;
std::unique_ptr<MasterSpace> master_;
std::vector<std::unique_ptr<MasterSpace>> slaves_;
std::weak_ptr<Client> client_;
};
#endif //YGGDRASILWM_MASTERSPACE_HPP
11 changes: 1 addition & 10 deletions inc/Layouts/TreeLayoutManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
* @file TreeLayoutManager
* @brief handle Tree Style Layout.
* @date 2024-02-05
* @date 2024-03-21
*/


Expand Down Expand Up @@ -152,17 +152,8 @@ class TreeLayoutManager :public LayoutManager {
*/
void growSpace(Client *client, int inc);
void recursiveShrinkSiblingSpace(BinarySpace *space, int inc, bool vertical);
/**
* @fn void TreeLayoutManager::shrinkSpaceX(Client* client)
* @brief shrink the space of the client in the y axis
* @todo this method is not implemented yet
* @param client
*/
void shrinkSpace(Client *client);
private:

std::unique_ptr<BinarySpace> rootSpace_;

void deleteSpace(BinarySpace *space);
};
#endif //YGGDRASILWM_TREELAYOUTMANAGER_HPP
1 change: 0 additions & 1 deletion src/Bars/Bars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ void Bars::run() {
try {
if (tsData->wait()) {
// Updated Data redraw
// Todo check for registerd keys to redraw only concerned widgets
std::unordered_map<std::string,std::string>updated = tsData->getData();
for (const auto &pair: updated) {
this->data[pair.first] = pair.second;
Expand Down
35 changes: 28 additions & 7 deletions src/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
* @file Group.cpp
* @brief Group class implementation.
* @date 2024-02-12
* @date 2024-03-21
*/
#include "WindowManager.hpp"
#include "Group.hpp"
Expand All @@ -42,10 +42,10 @@ Group::Group(const std::shared_ptr<ConfigDataGroup>& config,
layoutType = TREE;
} else if (config->getGroupLayout() == "Max") {
layoutType = MAX;
} else if (config->getGroupLayout() == "Vertical") {
layoutType = VERTICAL;
} else if (config->getGroupLayout() == "Horizontal") {
layoutType = HORIZONTAL;
} else if (config->getGroupLayout() == "MasterVertical") {
layoutType = MASTER_VERTICAL;
} else if (config->getGroupLayout() == "MasterHorizontal") {
layoutType = MASTER_HORIZONTAL;
} else {
layoutType = TREE;
}
Expand All @@ -72,8 +72,29 @@ Group::Group(const std::shared_ptr<ConfigDataGroup>& config,
barHeight_);
break;
case MAX:
case VERTICAL:
case HORIZONTAL:
break;
case MASTER_VERTICAL:
layoutManager_ = std::make_shared<TreeLayoutManager>(display,
root,
size_x,
size_y,
0,
0,
borderSize_,
gap_,
barHeight_);
break;
case MASTER_HORIZONTAL:
layoutManager_ = std::make_shared<TreeLayoutManager>(display,
root,
size_x,
size_y,
0,
0,
borderSize_,
gap_,
barHeight_);
break;
default:
layoutManager_ = std::make_shared<TreeLayoutManager>(display,
root,
Expand Down
60 changes: 60 additions & 0 deletions src/Layouts/MasterLayoutManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Yb dP 8 w 8 Yb dP 8b d8
* YbdP .d88 .d88 .d88 8d8b .d88 d88b w 8 Yb db dP 8YbmdP8
* YP 8 8 8 8 8 8 8P 8 8 `Yb. 8 8 YbdPYbdP 8 " 8
* 88 `Y88 `Y88 `Y88 8 `Y88 Y88P 8 8 YP YP 8 8
* wwdP wwdP
* Yggdrasil Window Manager
* https://github.com/corecaps/YggdrasilWM
* Copyright (C) 2024 jgarcia <[email protected]> <[email protected]>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
* @file MasterLayoutManager.cpp
* @brief handle Master Style Layout.
* @date 2024-03-21
*/

#include "Layouts/MasterLayoutManager.hpp"
#include "Layouts/MasterSpace.hpp"

void MasterLayoutManager::removeClient(Client *client) {

}

void MasterLayoutManager::addClient(std::shared_ptr<Client> client) {

}

void MasterLayoutManager::reSize(const Point &size, const Point &pos) {

}

void MasterLayoutManager::updateGeometry(unsigned int sizeX, unsigned int sizeY, unsigned int posX, unsigned int posY) {

}

MasterLayoutManager::MasterLayoutManager(Display *display,
Window root,
int sizeX,
int sizeY,
int posX,
int posY,
int borderSize,
int gap,
int barHeight) :
LayoutManager(display,root,sizeX,sizeY,posX,posY,gap,barHeight) {
Point pos(posX, posY);
Point size(sizeX - borderSize, sizeY - borderSize);
this->rootSpace_ = std::make_unique<MasterSpace>(pos, size,0, true, true);
}
64 changes: 64 additions & 0 deletions src/Layouts/MasterSpace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Yb dP 8 w 8 Yb dP 8b d8
* YbdP .d88 .d88 .d88 8d8b .d88 d88b w 8 Yb db dP 8YbmdP8
* YP 8 8 8 8 8 8 8P 8 8 `Yb. 8 8 YbdPYbdP 8 " 8
* 88 `Y88 `Y88 `Y88 8 `Y88 Y88P 8 8 YP YP 8 8
* wwdP wwdP
* Yggdrasil Window Manager
* https://github.com/corecaps/YggdrasilWM
* Copyright (C) 2024 jgarcia <[email protected]> <[email protected]>
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
* @file MasterSpace.cpp
* @brief MasterSpace class implementation.
* @date 2024-03-21
*/
#include "Layouts/MasterSpace.hpp"

MasterSpace::MasterSpace(Point pos,
Point size,
int index,
bool master,
bool vertical,
MasterSpace *parent) :
pos_(pos),
size_(size),
index_(index),
is_master_(master),
is_vertical_(vertical),
subspace_count_(0){
if (parent) {
parent_ = parent;
}
}
MasterSpace::~MasterSpace() = default;
const Point &MasterSpace::getPos() const { return pos_; }
void MasterSpace::setPos(const Point &pos) { pos_ = pos; }
const Point &MasterSpace::getSize() const { return size_; }
void MasterSpace::setSize(const Point &size) { size_ = size; }
bool MasterSpace::isMaster() const { return is_master_; }
void MasterSpace::setIsMaster(bool isMaster) { is_master_ = isMaster; }
bool MasterSpace::isVertical() const { return is_vertical_; }
void MasterSpace::setIsVertical(bool isVertical) { is_vertical_ = isVertical; }
int MasterSpace::getIndex() const { return index_; }
void MasterSpace::setIndex(int index) { index_ = index; }
int MasterSpace::getSubspaceCount() const { return subspace_count_; }
void MasterSpace::setSubspaceCount(int subspaceCount) { subspace_count_ = subspaceCount; }
MasterSpace *MasterSpace::getParent() const { return parent_; }
void MasterSpace::setParent(MasterSpace *parent) { parent_ = parent; }
MasterSpace *MasterSpace::getMaster() const { return master_.get(); }
void MasterSpace::setMaster(std::unique_ptr<MasterSpace> master) { master_ = std::move(master); }
const std::vector<std::unique_ptr<MasterSpace>> &MasterSpace::getSlaves() const { return slaves_; }
const std::weak_ptr<Client> &MasterSpace::getClient() const { return client_; }
void MasterSpace::setClient(const std::weak_ptr<Client> &client) { client_ = client; }
Loading

0 comments on commit 4cffe71

Please sign in to comment.