src/modules/xworkspaces.cpp
/**
   * Update active state of current desktops
   */
Update active state of current desktops
Update active state of current desktops
void xworkspaces_module::rebuild_desktop_states() {
    std::set<unsigned int> occupied_desks;
    for (auto&& c : m_clients) {
      occupied_desks.insert(c.second);
    }
    for (auto&& v : m_viewports) {
      for (auto&& d : v->desktops) {
        if (m_urgent_desktops[d->index]) {
          d->state = desktop_state::URGENT;
        } else if (d->index == m_current_desktop) {
          d->state = desktop_state::ACTIVE;
        } else if (occupied_desks.count(d->index) > 0) {
          d->state = desktop_state::OCCUPIED;
        } else {
          d->state = desktop_state::EMPTY;
        }
        d->label = m_labels.at(d->state)->clone();
        d->label->reset_tokens();
        d->label->replace_token("%index%", to_string(d->index + 1));
        d->label->replace_token("%name%", m_desktop_names[d->index]);
        d->label->replace_token("%nwin%", to_string(m_windows[d->index]));
        d->label->replace_token("%icon%", m_icons->get(m_desktop_names[d->index], DEFAULT_ICON)->get());
      }
    }
  }
void xworkspaces_module :: rebuild_desktop_states ( ) { std :: set < unsigned int > occupied_desks ; for ( auto && c : m_clients ) { occupied_desks . insert ( c . second ) ; } for ( auto && v : m_viewports ) { for ( auto && d : v -> desktops ) { if ( m_urgent_desktops [ d -> index ] ) { d -> state = desktop_state :: URGENT ; } else if ( d -> index == m_current_desktop ) { d -> state = desktop_state :: ACTIVE ; } else if ( occupied_desks . count ( d -> index ) > 0 ) { d -> state = desktop_state :: OCCUPIED ; } else { d -> state = desktop_state :: EMPTY ; } d -> label = m_labels . at ( d -> state ) -> clone ( ) ; d -> label -> reset_tokens ( ) ; d -> label -> replace_token ( " " , to_string ( d -> index + 1 ) ) ; d -> label -> replace_token ( " " , m_desktop_names [ d -> index ] ) ; d -> label -> replace_token ( " " , to_string ( m_windows [ d -> index ] ) ) ; d -> label -> replace_token ( " " , m_icons -> get ( m_desktop_names [ d -> index ] , DEFAULT_ICON ) -> get ( ) ) ; } } }
Update active state of current desktops
Update active state of current desktops