Initial implementation of active window

TODO:
- Sometimes the active event arrives before the create, in which case the window is not activated.
- The window title event also looks unreliable in some cases, will need to investigate
This commit is contained in:
Pol Rivero
2025-05-01 20:22:18 +02:00
parent 59c270ec06
commit 72404a77f0
6 changed files with 57 additions and 5 deletions

View File

@ -103,6 +103,16 @@ void Workspace::initializeWindowMap(const Json::Value &clients_data) {
}
}
void Workspace::setActiveWindow(WindowAddress const &addr) {
for (auto &window : m_windowMap) {
if (window.address == addr) {
window.setActive(true);
} else {
window.setActive(false);
}
}
}
void Workspace::insertWindow(WindowCreationPayload create_window_paylod) {
if (!create_window_paylod.isEmpty(m_workspaceManager)) {
auto repr = create_window_paylod.repr(m_workspaceManager);
@ -259,6 +269,9 @@ void Workspace::updateTaskbar(const std::string &workspace_icon) {
auto window_box = Gtk::make_managed<Gtk::Box>(Gtk::ORIENTATION_HORIZONTAL);
window_box->set_tooltip_text(window_repr.window_title);
window_box->get_style_context()->add_class("taskbar-window");
if (window_repr.isActive) {
window_box->get_style_context()->add_class("active");
}
auto event_box = Gtk::manage(new Gtk::EventBox());
event_box->add(*window_box);
if (m_workspaceManager.onClickWindow() != "") {