src/components/bar.cpp
/**
 * Event handler for XCB_BUTTON_PRESS events
 *
 * Used to map mouse clicks to bar actions
 */
Event handler for XCB_BUTTON_PRESS events
Used to map mouse clicks to bar actions
Event handler for XCB_BUTTON_PRESS events Used to map mouse clicks to bar actions
void bar::handle(const evt::button_press& evt) {
  m_log.trace("bar: Received button press: %i at pos(%i, %i)", evt->detail, evt->event_x, evt->event_y);
  mousebtn btn = static_cast<mousebtn>(evt->detail);
  int pos = evt->event_x;
  const auto check_double = [this](TimerHandle_t handle, mousebtn btn, int pos) {
    if (!handle->is_active()) {
      handle->start(m_opts.double_click_interval, 0, [=]() { trigger_click(btn, pos); });
    } else {
      handle->stop();
      trigger_click(mousebtn_get_double(btn), pos);
    }
  };
  if (!m_dblclicks) {
    trigger_click(btn, pos);
  } else if (btn == mousebtn::LEFT) {
    check_double(m_leftclick_timer, btn, pos);
  } else if (btn == mousebtn::MIDDLE) {
    check_double(m_middleclick_timer, btn, pos);
  } else if (btn == mousebtn::RIGHT) {
    check_double(m_rightclick_timer, btn, pos);
  } else {
    trigger_click(btn, pos);
  }
}
void bar :: handle ( const evt :: button_press & evt ) { m_log . trace ( " " , evt -> detail , evt -> event_x , evt -> event_y ) ; mousebtn btn = static_cast < mousebtn > ( evt -> detail ) ; int pos = evt -> event_x ; const auto check_double = [ this ] ( TimerHandle_t handle , mousebtn btn , int pos ) { if ( ! handle -> is_active ( ) ) { handle -> start ( m_opts . double_click_interval , 0 , [ = ] ( ) { trigger_click ( btn , pos ) ; } ) ; } else { handle -> stop ( ) ; trigger_click ( mousebtn_get_double ( btn ) , pos ) ; } } ; if ( ! m_dblclicks ) { trigger_click ( btn , pos ) ; } else if ( btn == mousebtn :: LEFT ) { check_double ( m_leftclick_timer , btn , pos ) ; } else if ( btn == mousebtn :: MIDDLE ) { check_double ( m_middleclick_timer , btn , pos ) ; } else if ( btn == mousebtn :: RIGHT ) { check_double ( m_rightclick_timer , btn , pos ) ; } else { trigger_click ( btn , pos ) ; } }
Event handler for XCB_BUTTON_PRESS events
 Used to map mouse clicks to bar actions
Event handler for XCB_BUTTON_PRESS events Used to map mouse clicks to bar actions
/*
   * For possible double-clicks we need to delay the triggering of the click by
   * the configured interval and if in that time another click arrives, we
   * need to trigger a double click.
   */ // If there are no double click handlers defined we can // just by-pass the click timer handling