Пример #1
0
static int
glw_nav_last(glw_t *parent)
{
  glw_t *c = glw_last_widget(parent);

  while(c != NULL) {
    glw_t *to_focus = glw_get_focusable_child(c);
    if(to_focus != NULL && to_focus->glw_flags2 & GLW2_NAV_FOCUSABLE) {
      glw_focus_set(to_focus->glw_root, to_focus, GLW_FOCUS_SET_INTERACTIVE,
                    "NavLast");
      return 1;
    }
    c = glw_prev_widget(c);
  }
  return 0;
}
Пример #2
0
void
glw_scroll_suggest_focus(glw_scroll_control_t *gsc, glw_t *w, glw_t *c)
{
  if(!glw_is_focused(w)) {
    w->glw_focused = c;
    glw_signal0(w, GLW_SIGNAL_FOCUS_CHILD_INTERACTIVE, c);
    gsc->scroll_to_me = c;
    return;
  }

  if(gsc->suggested == w->glw_focused || gsc->suggest_cnt > 0) {
    c = glw_focus_by_path(c);
    if(c != NULL)
      glw_focus_set(c->glw_root, c, GLW_FOCUS_SET_SUGGESTED, "Suggested");
    gsc->suggest_cnt = 1;
  }
  gsc->suggested = c;
  gsc->suggest_cnt++;
}
Пример #3
0
void
glw_scroll_handle_scroll(glw_scroll_control_t *gsc, glw_t *w, glw_scroll_t *gs)
{
  int top = GLW_MAX(gs->value * (gsc->total_size - gsc->page_size
                                 + gsc->scroll_threshold_post), 0);
  gsc->target_pos = top;
  glw_schedule_refresh(w->glw_root, 0);

  if(gsc->chase_focus == 0)
    return;

  glw_t *c = w->glw_class->gc_find_visible_child(w);
  if(c == NULL)
    return;

  if(glw_is_focused(w)) {
    glw_focus_set(w->glw_root, c, GLW_FOCUS_SET_SUGGESTED, "Scroll");
  } else {
    w->glw_focused = c;
    glw_signal0(w, GLW_SIGNAL_FOCUS_CHILD_INTERACTIVE, c);
  }
}
Пример #4
0
int
glw_navigate_step(glw_t *c, int count, int may_wrap)
{
  glw_t *parent = c->glw_parent;
  glw_t *to_focus = NULL;
  int forward = 1;

  if(count < 0) {
    forward = 0;
    count = -count;
  }

  while((c = glw_step_widget(c, forward)) != NULL) {
    glw_t *tentative = glw_get_focusable_child(c);
    if(tentative != NULL) {
      if(!(tentative->glw_flags2 & GLW2_NAV_FOCUSABLE))
        continue;

      to_focus = tentative;
      count--;
      if(count == 0)
         break;
    }
  }

  if(to_focus != NULL) {
    glw_focus_set(to_focus->glw_root, to_focus, GLW_FOCUS_SET_INTERACTIVE,
                  "NavStep");
    return 1;
  } else if(may_wrap) {
    if(forward) {
      return glw_nav_first(parent);
    } else {
      return glw_nav_last(parent);
    }
  }

  return 0;
}