src/modules/xworkspaces.cpp
/**
   * Focuses either the next or previous desktop.
   *
   * Will wrap around at the ends and go in the order the desktops are displayed.
   */
Focuses either the next or previous desktop.
Will wrap around at the ends and go in the order the desktops are displayed.
Focuses either the next or previous desktop . Will wrap around at the ends and go in the order the desktops are displayed .
void xworkspaces_module::focus_direction(bool next) {
    unsigned int current_desktop{ewmh_util::get_current_desktop()};
    int current_index = -1;
    vector<unsigned int> indices;
    for (auto&& viewport : m_viewports) {
      for (auto&& desktop : viewport->desktops) {
        if (current_desktop == desktop->index) {
          current_index = indices.size();
        }
        indices.emplace_back(desktop->index);
      }
    }
    if (current_index == -1) {
      m_log.err("%s: Current desktop (%u) not found in list of desktops", name(), current_desktop);
      return;
    }
    int offset = next ? 1 : -1;
    int new_index = (current_index + offset + indices.size()) % indices.size();
    focus_desktop(indices.at(new_index));
  }
void xworkspaces_module :: focus_direction ( bool next ) { unsigned int current_desktop { ewmh_util :: get_current_desktop ( ) } ; int current_index = -1 ; vector < unsigned int > indices ; for ( auto && viewport : m_viewports ) { for ( auto && desktop : viewport -> desktops ) { if ( current_desktop == desktop -> index ) { current_index = indices . size ( ) ; } indices . emplace_back ( desktop -> index ) ; } } if ( current_index == -1 ) { m_log . err ( " " , name ( ) , current_desktop ) ; return ; } int offset = next ? 1 : -1 ; int new_index = ( current_index + offset + indices . size ( ) ) % indices . size ( ) ; focus_desktop ( indices . at ( new_index ) ) ; }
Focuses either the next or previous desktop.
Focuses either the next or previous desktop .
/*
     * Desktop indices in the order they are displayed.
     */