src/components/bar.cpp
/**
 * Parse input string and redraw the bar window
 *
 * \param data Input string
 * \param force Unless true, do not parse unchanged data
 */
Parse input string and redraw the bar window
\param data Input string
\param force Unless true, do not parse unchanged data
Parse input string and redraw the bar window \ param data Input string \ param force Unless true do not parse unchanged data
void bar::parse(string&& data, bool force) {
  bool unchanged = data == m_lastinput;
  m_lastinput = data;
  if (force) {
    m_log.trace("bar: Force update");
  } else if (!m_visible) {
    return m_log.trace("bar: Ignoring update (invisible)");
  } else if (unchanged) {
    return m_log.trace("bar: Ignoring update (unchanged)");
  }
  auto rect = m_opts.inner_area();
  if (m_tray && !m_tray->settings().detached && m_tray->settings().configured_slots) {
    auto trayalign = m_tray->settings().align;
    auto traywidth = m_tray->settings().configured_w;
    if (trayalign == alignment::LEFT) {
      rect.x += traywidth;
      rect.width -= traywidth;
    } else if (trayalign == alignment::RIGHT) {
      rect.width -= traywidth;
    }
  }
  m_log.info("Redrawing bar window");
  m_renderer->begin(rect);
  try {
    m_dispatch->parse(settings(), *m_renderer, std::move(data));
  } catch (const exception& err) {
    m_log.err("Failed to parse contents (reason: %s)", err.what());
  }
  m_renderer->end();
  const auto check_dblclicks = [&]() -> bool {
    if (m_action_ctxt->has_double_click()) {
      return true;
    }
    for (auto&& action : m_opts.actions) {
      if (static_cast<int>(action.button) >= static_cast<int>(mousebtn::DOUBLE_LEFT)) {
        return true;
      }
    }
    return false;
  };
  m_dblclicks = check_dblclicks();
}
void bar :: parse ( string && data , bool force ) { bool unchanged = data == m_lastinput ; m_lastinput = data ; if ( force ) { m_log . trace ( " " ) ; } else if ( ! m_visible ) { return m_log . trace ( " " ) ; } else if ( unchanged ) { return m_log . trace ( " " ) ; } auto rect = m_opts . inner_area ( ) ; if ( m_tray && ! m_tray -> settings ( ) . detached && m_tray -> settings ( ) . configured_slots ) { auto trayalign = m_tray -> settings ( ) . align ; auto traywidth = m_tray -> settings ( ) . configured_w ; if ( trayalign == alignment :: LEFT ) { rect . x += traywidth ; rect . width -= traywidth ; } else if ( trayalign == alignment :: RIGHT ) { rect . width -= traywidth ; } } m_log . info ( " " ) ; m_renderer -> begin ( rect ) ; try { m_dispatch -> parse ( settings ( ) , * m_renderer , std :: move ( data ) ) ; } catch ( const exception & err ) { m_log . err ( " " , err . what ( ) ) ; } m_renderer -> end ( ) ; const auto check_dblclicks = [ & ] ( ) -> bool { if ( m_action_ctxt -> has_double_click ( ) ) { return true ; } for ( auto && action : m_opts . actions ) { if ( static_cast < int > ( action . button ) >= static_cast < int > ( mousebtn :: DOUBLE_LEFT ) ) { return true ; } } return false ; } ; m_dblclicks = check_dblclicks ( ) ; }
Parse input string and redraw the bar window
 \param data Input string
 \param force Unless true, do not parse unchanged data
Parse input string and redraw the bar window \ param data Input string \ param force Unless true do not parse unchanged data