Пример #1
0
int w_clistbox_item_del (w_object_t *object, w_clistbox_item_t *item)
{
	int p;
	w_clistbox_t *lb;
	w_clistbox_item_t *active;
	lb = object->data[OBJECT_CLISTBOX];
	active = s_list_get(lb->items, lb->active);
	p = s_list_get_pos(lb->items, item);
	s_list_remove(lb->items, p);
	w_clistbox_item_uninit(item);
	if (lb->active == p) {
		active = s_list_get(lb->items, p);
		if (active == NULL) {
			active = s_list_get(lb->items, p - 1);
		} else {
			lb->pactive = -1;
		}
	}
	if (active == NULL) {
		lb->active = 0;
	} else {
		lb->active = s_list_get_pos(lb->items, active);
	}
	if (lb->active < 0) {
		lb->active = 0;
	}
	lb->dirty = 1;
	w_object_draw(object);
	return 0;
}
Пример #2
0
int s_handler_del (s_window_t *window, s_handler_t *handler)
{
	int ret = 0;
	s_thread_mutex_lock(window->handlers->mut);
	ret = s_list_remove(window->handlers->list, s_list_get_pos(window->handlers->list, handler));
	s_thread_mutex_unlock(window->handlers->mut);
	return ret;
}
Пример #3
0
static void timer1_cb (s_window_t *window, s_timer_t *timer)
{
	debugf(DCLI, "[%d]", window->id);
	s_thread_mutex_lock(window->timers->mut);
	if (s_list_get_pos(window->timers->timers, timer) >= 0) {
		debugf(DCLI, "[%d] found!", window->id);
	}
	s_thread_mutex_unlock(window->timers->mut);
}
Пример #4
0
int s_pollfd_del (s_window_t *window, s_pollfd_t *pfd)
{
	int ret;
	s_thread_mutex_lock(window->pollfds->mut);
	ret = s_list_remove(window->pollfds->list, s_list_get_pos(window->pollfds->list, pfd));
	s_thread_mutex_unlock(window->pollfds->mut);
	s_window_wakeup(window);
	return ret;
}
Пример #5
0
int s_event_parse_handler_over (s_window_t *window, s_event_t *event, s_handler_t *work)
{
	switch (s_event_mouse_handler_state(window, event, &(work->mouse), 1)) {
		case MOUSE_OVER:
			if (work->mouse.o != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.o(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			goto not_over;
		case MOUSE_PRESSED:
			if (work->mouse.p != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.p(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			goto not_over;
		case MOUSE_CLICKED:
			if (work->mouse.c != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.c(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
				work = (s_handler_t *) s_list_get(window->handlers->list, s_list_get_pos(window->handlers->list, work));
				if (work == NULL) {
					goto not_over;
				}
			}
			/* no break */
		case MOUSE_RELEASED:
			if (work->mouse.r != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.r(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			goto not_over;
		case (MOUSE_RELEASED | MOUSE_HINT):
			/* mouse button released, but the prev. press was not on us */
			if (work->mouse.hr != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.hr(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			goto not_over;
		case (MOUSE_OVER | MOUSE_HINT):
			/* on over, but mouse button is still pressed */
			if (work->mouse.ho != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.ho(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			goto not_over;
	}
	return -1;
not_over:
	return 0;
}
Пример #6
0
int s_handler_add (s_window_t *window, s_handler_t *handler)
{
	int ret = 0;
	s_thread_mutex_lock(window->handlers->mut);
	if (s_list_get_pos(window->handlers->list, handler) < 0) {
		ret = s_list_add(window->handlers->list, handler, -1);
	}
	s_thread_mutex_unlock(window->handlers->mut);
	return ret;
}
Пример #7
0
int w_clistbox_item_active_set (w_object_t *object, w_clistbox_item_t *listbox_item)
{
	int active;
	w_clistbox_t *lb;
	lb = object->data[OBJECT_CLISTBOX];
	active = s_list_get_pos(lb->items, listbox_item);
	if (active < 0) {
		return -1;
	}
	lb->active = active;
	w_object_draw(object);
	return 0;
}
Пример #8
0
int w_clistbox_item_add (w_object_t *object, w_clistbox_item_t *item)
{
	w_clistbox_t *lb;
	w_clistbox_item_t *active;
	lb = object->data[OBJECT_CLISTBOX];
	active = s_list_get(lb->items, lb->active);
	s_list_add(lb->items, item, -1);
	if (active == NULL) {
		lb->active = 0;
	} else {
		lb->active = s_list_get_pos(lb->items, active);
	}
//	w_object_draw(object);
	return 0;
}
Пример #9
0
int s_pollfd_add (s_window_t *window, s_pollfd_t *pfd)
{
	int ret = 0;
	s_thread_mutex_lock(window->pollfds->mut);
	if (s_list_get_pos(window->pollfds->list, pfd) < 0) {
#if 1
		ret = s_list_add(window->pollfds->list, pfd, -1);
#else
		ret = s_list_add(window->pollfds->list, pfd, 2);
#endif
	}
	s_thread_mutex_unlock(window->pollfds->mut);
	s_window_wakeup(window);
	return ret;
}
Пример #10
0
int s_dir_find_pos (s_dir_t *dir)
{
	int r;
	r = s_list_get_pos(dir->up->dirs, dir);
	return r;
}