| 12 | namespace waybar::modules::hyprland { |
| 13 | |
| 14 | Workspace::Workspace(const Json::Value& workspace_data, Workspaces& workspace_manager, |
| 15 | const Json::Value& clients_data) |
| 16 | : m_workspaceManager(workspace_manager), |
| 17 | m_id(workspace_data["id"].asInt()), |
| 18 | m_name(workspace_data["name"].asString()), |
| 19 | m_output(workspace_data["monitor"].asString()), // TODO:allow using monitor desc |
| 20 | m_windows(workspace_data["windows"].asInt()), |
| 21 | m_isActive(true), |
| 22 | m_isPersistentRule(workspace_data["persistent-rule"].asBool()), |
| 23 | m_isPersistentConfig(workspace_data["persistent-config"].asBool()), |
| 24 | m_ipc(IPC::inst()) { |
| 25 | if (m_name.starts_with("name:")) { |
| 26 | m_name = m_name.substr(5); |
| 27 | } else if (m_name.starts_with("special")) { |
| 28 | m_name = m_id == -99 ? m_name : m_name.substr(8); |
| 29 | m_isSpecial = true; |
| 30 | } |
| 31 | |
| 32 | m_button.add_events(Gdk::BUTTON_PRESS_MASK); |
| 33 | m_button.signal_button_press_event().connect(sigc::mem_fun(*this, &Workspace::handleClicked), |
| 34 | false); |
| 35 | |
| 36 | m_button.set_relief(Gtk::RELIEF_NONE); |
| 37 | if (m_workspaceManager.enableTaskbar()) { |
| 38 | m_content.set_orientation(m_workspaceManager.taskbarOrientation()); |
| 39 | m_content.pack_start(m_labelBefore, false, false); |
| 40 | } else { |
| 41 | m_content.set_center_widget(m_labelBefore); |
| 42 | } |
| 43 | m_button.add(m_content); |
| 44 | |
| 45 | initializeWindowMap(clients_data); |
| 46 | } |
| 47 | |
| 48 | void addOrRemoveClass(const Glib::RefPtr<Gtk::StyleContext>& context, bool condition, |
| 49 | const std::string& class_name) { |
nothing calls this directly
no test coverage detected