Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyprland/workspaces improvements #2316

Merged
merged 19 commits into from
Jul 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
moves createWorkspace to update()
  • Loading branch information
MightyPlaza authored Jul 16, 2023
commit 5f0fa71f3204bd2ff1b905c36e05555e11a12ccd
14 changes: 8 additions & 6 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
@@ -64,10 +64,12 @@ auto Workspaces::update() -> void {

workspaces_to_remove_.clear();

for (int &workspace_to_create : workspaces_to_create_) {
for (Json::Value &workspace_to_create : workspaces_to_create_) {
create_workspace(workspace_to_create);
}

workspaces_to_create_.clear();

for (auto &workspace : workspaces_) {
workspace->set_active(workspace->name() == active_workspace_name);
std::string &workspace_icon = icons_map_[""];
@@ -92,7 +94,7 @@ void Workspaces::onEvent(const std::string &ev) {

} else if (eventName == "createworkspace") {
const Json::Value workspaces_json = gIPC->getSocket1JsonReply("workspaces");
for (auto &workspace_json : workspaces_json) {
for (Json::Value workspace_json : workspaces_json) {
if (workspace_json["name"].asString() == payload &&
(all_outputs() || bar_.output->name == workspace_json["monitor"].asString()) &&
(workspace_json["name"].asString().find("special:") != 0 || show_special()))
@@ -107,10 +109,10 @@ void Workspaces::onEvent(const std::string &ev) {
std::string new_output = payload.substr(payload.find(",") + 1);
if (bar_.output->name == new_output) { // TODO: implement this better
const Json::Value workspaces_json = gIPC->getSocket1JsonReply("workspaces");
for (auto &workspace_json : workspaces_json) {
for (Json::Value workspace_json : workspaces_json) {
if (workspace_json["name"].asString() == workspace &&
bar_.output->name == workspace_json["monitor"].asString()) {
create_workspace(workspace_json);
workspaces_to_create_.push_back(workspace_json);
break;
}
}
@@ -122,7 +124,7 @@ void Workspaces::onEvent(const std::string &ev) {
dp.emit();
}

void Workspaces::create_workspace(const Json::Value &value) {
void Workspaces::create_workspace(Json::Value &value) {
workspaces_.push_back(std::make_unique<Workspace>(value));
Gtk::Button &new_workspace_button = workspaces_.back()->button();
box_.pack_start(new_workspace_button, false, false);
@@ -146,7 +148,7 @@ void Workspaces::init() {
active_workspace_name = (gIPC->getSocket1JsonReply("activeworkspace"))["name"].asString();

const Json::Value workspaces_json = gIPC->getSocket1JsonReply("workspaces");
for (const Json::Value &workspace_json : workspaces_json) {
for (Json::Value workspace_json : workspaces_json) {
if ((all_outputs() || bar_.output->name == workspace_json["monitor"].asString()) &&
(workspace_json["name"].asString().find("special") != 0 || show_special()))
create_workspace(workspace_json);