feat: attempt to move windows out of the create window payload before taking them from workspaces

This commit is contained in:
Brenno Lemos 2023-10-18 19:04:09 -03:00
parent 6ddd283d0f
commit 193040c41e
2 changed files with 18 additions and 1 deletions

View File

@ -41,6 +41,8 @@ class CreateWindow {
std::string workspace_name() const { return workspace_name_; } std::string workspace_name() const { return workspace_name_; }
WindowAddress addr() const { return window_address_; } WindowAddress addr() const { return window_address_; }
void move_to_worksace(std::string& new_workspace_name);
private: private:
void clear_addr(); void clear_addr();
void clear_workspace_name(); void clear_workspace_name();

View File

@ -367,6 +367,15 @@ void Workspaces::on_window_moved(std::string payload) {
std::string window_repr; std::string window_repr;
// If the window was still queued to be created, just change its destination
// and exit
for (auto &window : windows_to_create_) {
if (window.addr() == window_address) {
window.move_to_worksace(workspace_name);
return;
}
}
// Take the window's representation from the old workspace... // Take the window's representation from the old workspace...
for (auto &workspace : workspaces_) { for (auto &workspace : workspaces_) {
try { try {
@ -379,7 +388,9 @@ void Workspaces::on_window_moved(std::string payload) {
} }
// ...and add it to the new workspace // ...and add it to the new workspace
windows_to_create_.emplace_back(CreateWindow(workspace_name, window_address, window_repr)); if (!window_repr.empty()) {
windows_to_create_.emplace_back(CreateWindow(workspace_name, window_address, window_repr));
}
} }
void Workspaces::update_window_count() { void Workspaces::update_window_count() {
@ -934,4 +945,8 @@ void CreateWindow::clear_workspace_name() {
} }
} }
void CreateWindow::move_to_worksace(std::string &new_workspace_name) {
workspace_name_ = new_workspace_name;
}
} // namespace waybar::modules::hyprland } // namespace waybar::modules::hyprland