Example #1
0
void
KeyAxisEventHandler::send(int value)
{
  int old_zone = get_zone(m_old_value);
  int zone     = get_zone(value);

  if (old_zone != zone)
  {
    // release the keys of the zone we leave
    if (old_zone == -1)
    {
      send_up(false);
    }
    else if (old_zone == +1)
    {
      send_down(false);
    }

    // press the keys of the zone we enter
    if (zone == +1)
    {
      send_down(true);
    }
    else if (zone == -1)
    {
      send_up(true);
    }
  }

  m_old_value = value;
}
Example #2
0
int gcomm::PC::handle_down(Datagram& wb, const ProtoDownMeta& dm)
{
    if (wb.len() == 0)
    {
        gu_throw_error(EMSGSIZE);
    }
    return send_down(wb, dm);
}
Example #3
0
void Touch::sendDown(int touch_id, const QPointF &position)
{
    if (!m_focusResource || !m_focus)
        return;

    uint32_t serial = wl_display_next_serial(m_compositor->wl_display());

    send_down(m_focusResource->handle, serial, Compositor::currentTimeMsecs(), m_focus->resource()->handle, touch_id,
              wl_fixed_from_double(position.x()), wl_fixed_from_double(position.y()));
}
Example #4
0
TEST(state, capsule_carries_its_own_watchers)
{
  auto sig = std::shared_ptr<detail::state_up_down_signal<int>>{};
  auto s = testing::spy();
  {
    auto st = make_state(42);
    sig = detail::access::signal(st);
    watch(st, s);
    sig->push_down(12);
    sig->send_down();
    sig->notify();
    EXPECT_EQ(1, s.count());
  }
  sig->push_down(7);
  sig->send_down();
  sig->notify();
  EXPECT_EQ(1, s.count());
  EXPECT_TRUE(sig->observers().empty());
}
Example #5
0
static void
remove_from_heap(sel_timer_t **top, sel_timer_t **last, sel_timer_t *elem)
{
    sel_timer_t *to_insert;

#ifdef MASSIVE_DEBUG
    fprintf(*debug_out, "remove_from_head entry\n");
    print_tree(*top, *last);
    check_tree(*top, *last);
#endif

    /* First remove the last element from the tree, if it's not what's
       being removed, we will use it for insertion into the removal
       place. */
    to_insert = *last;
    if (! to_insert->up) {
	/* This is the only element in the heap. */
	*top = NULL;
	*last = NULL;
	goto out;
    } else {
	/* Set the new last position, and remove the item we will
           insert. */
	find_prev_elem(to_insert, last);
	if (to_insert->up->left == to_insert) {
	    to_insert->up->left = NULL;
	} else {
	    to_insert->up->right = NULL;
	}
    }

    if (elem == to_insert) {
	/* We got lucky and removed the last element.  We are done. */
	goto out;
    }

    /* Now stick the formerly last element into the removed element's
       position. */
    if (elem->up) {
	if (elem->up->left == elem) {
	    elem->up->left = to_insert;
	} else {
	    elem->up->right = to_insert;
	}
    } else {
	/* The head of the tree is being replaced. */
	*top = to_insert;
    }
    to_insert->up = elem->up;
    if (elem->left)
	elem->left->up = to_insert;
    if (elem->right)
	elem->right->up = to_insert;
    to_insert->left = elem->left;
    to_insert->right = elem->right;

    if (*last == elem)
	*last = to_insert;

    elem = to_insert;

    /* Now propigate it to the right place in the tree. */
    if (elem->up && cmp_timeval(&elem->timeout, &elem->up->timeout) < 0) {
	send_up(elem, top, last);
    } else {
	send_down(elem, top, last);
    }

 out:
#ifdef MASSIVE_DEBUG
    fprintf(*debug_out, "remove_from_head exit\n");
    print_tree(*top, *last);
    check_tree(*top, *last);
#endif
    return;
}