Beispiel #1
0
static int lxynth_vscroll (struct graphics_device *dev, struct rect_set **ignore, int sc)
{
	s_rect_t rect;
	lxynth_device_t *wd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	VSCROLL_CLIP_PREFACE;

        if (lxynth_root->running == 0) return;
        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}

	wd = (lxynth_device_t *) dev->driver_data;

	ignore = NULL;

	rect.x = dev->clip.x1;
	rect.y = dev->clip.y1;
	rect.w = dev->clip.x2 - dev->clip.x1;
	rect.h = dev->clip.y2 - dev->clip.y1;

        s_copybox(wd->surface, rect.x, rect.y, rect.w, rect.h, rect.x, rect.y + sc);
	lxynth_surface_update(dev, rect.x, rect.y, rect.w, rect.h);
	s_thread_mutex_unlock(lxynth_root->gd->mut);

	return 1;
}
Beispiel #2
0
int s_event_parse_handler_notover (s_window_t *window, s_event_t *event, s_handler_t *work)
{
	switch (s_event_mouse_handler_state(window, event, &(work->mouse), 0)) {
		case (MOUSE_OVER | MOUSE_HINT2):
			/* not on over, but was on over */
			if (work->mouse.oh != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.oh(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			goto end;
		case (MOUSE_OVER | MOUSE_HINT | MOUSE_HINT2):
			/* not on over, but was on over. and button is still pressed */
			if (work->mouse.hoh != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.hoh(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			goto end;
		case (MOUSE_RELEASED | MOUSE_HINT2):
			/* mouse button released outside, but the prev. press was on us */
			if (work->mouse.rh != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->mouse.rh(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			goto end;
	}
	return -1;
end:	return 0;
} 
Beispiel #3
0
static void lxynth_set_clip_area (struct graphics_device *dev, struct rect *r)
{
	lxynth_device_t *wd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}

	wd = (lxynth_device_t *) dev->driver_data;

	memcpy(&dev->clip, r, sizeof(struct rect));
	if ((dev->clip.x1 >= dev->clip.x2) ||
	    (dev->clip.y2 <= dev->clip.y1) ||
	    (dev->clip.y2 <= 0) ||
	    (dev->clip.x2 <= 0) ||
	    (dev->clip.x1 >= wd->surface->width) ||
	    (dev->clip.y1 >= wd->surface->height)) {
		dev->clip.x1 = dev->clip.x2 = dev->clip.y1 = dev->clip.y2 = 0;
	} else {
		if (dev->clip.x1 < 0) dev->clip.x1 = 0;
		if (dev->clip.x2 > wd->surface->width) dev->clip.x2 = wd->surface->width;
		if (dev->clip.y1 < 0) dev->clip.y1 = 0;
		if (dev->clip.y2 > wd->surface->height) dev->clip.y2 = wd->surface->height;
	}
	s_thread_mutex_unlock(lxynth_root->gd->mut);
}
Beispiel #4
0
static void lxynth_surface_register_update (void *dev)
{
	lxynth_device_t *wd;
        if (lxynth_root->running == 0) return;
        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}
	wd = (lxynth_device_t *) ((struct graphics_device *) dev)->driver_data;
	s_putboxpart(lxynth_root->window->surface, wd->update.x, wd->update.y, wd->update.w, wd->update.h, wd->surface->width, wd->surface->height, wd->surface->vbuf, wd->update.x, wd->update.y);
	wd->update = (s_rect_t) {-1, -1, -1, -1};
	s_thread_mutex_unlock(lxynth_root->gd->mut);
}
Beispiel #5
0
static void lxynth_atevent (s_window_t *window, s_event_t *event)
{
        s_event_t *e;

        if (lxynth_root == NULL) {
		return;
	}
	switch (event->type & EVENT_MASK) {
		case QUIT_EVENT:
		case MOUSE_EVENT:
		case KEYBD_EVENT:
		case EXPOSE_EVENT:
		case CONFIG_EVENT:
		case FOCUS_EVENT:
			if (!s_event_init(&e)) {
				e->type = event->type;
				memcpy(e->mouse, event->mouse, sizeof(s_mouse_t));
				memcpy(e->keybd, event->keybd, sizeof(s_keybd_t));
				memcpy(e->expose->rect, event->expose->rect, sizeof(s_rect_t));
				s_thread_mutex_lock(lxynth_root->eventq->mut);
				s_list_add(lxynth_root->eventq->list, e, -1);
				s_thread_mutex_unlock(lxynth_root->eventq->mut);
			}
			break;
		default:
			break;
	}
}
Beispiel #6
0
int s_eventq_wait (s_window_t *window, s_event_t **event)
{
        int ret;
        s_event_t *e;

	s_thread_mutex_lock(window->eventq->mut);

	while (window->eventq->queue->nb_elt <= 0) {
		if (s_thread_cond_wait(window->eventq->cond, window->eventq->mut)) {
			debugf(DSYS, "s_thread_cond_wait failed");
			return -1;
		}
	}

	e = (s_event_t *) s_list_get(window->eventq->queue, 0);
	if (e == NULL) {
		ret = -1;
	} else {
		s_list_remove(window->eventq->queue, 0);
		*event = e;
		ret = 0;
	}

	s_thread_mutex_unlock(window->eventq->mut);

	return ret;
}
Beispiel #7
0
void s_event_parse_mouse (s_window_t *window, s_event_t *event)
{
        int pos;
	s_handler_t *work;
        pos = 0;
	s_thread_mutex_lock(window->handlers->mut);
	while (!s_list_eol(window->handlers->list, pos)) {
		work = (s_handler_t *) s_list_get(window->handlers->list, pos++);
		if (work->type != MOUSE_HANDLER) {
			continue;
		}
		if (s_event_parse_handler_over(window, event, work) == 0) {
			break;
		}
	}
	pos = 0;
	while (!s_list_eol(window->handlers->list, pos)) {
		work = (s_handler_t *) s_list_get(window->handlers->list, pos++);
		if (work->type != MOUSE_HANDLER) {
			continue;
		}
		if (s_event_parse_handler_notover(window, event, work) == 0) {
			break;
		}
	}
	s_thread_mutex_unlock(window->handlers->mut);
	
	return;
}
Beispiel #8
0
/**
 * \brief Checks if an effect is running
 *
 * \return Returns true if a window effect is currently running
 */
bool GuiEffectWindow::effectInProgress()
{
	s_thread_mutex_lock(effectMutex);
	bool ret = effectTimer != NULL;
	s_thread_mutex_unlock(effectMutex);
	return ret;
}
Beispiel #9
0
static void lxynth_timer (void *arg)
{
        int x = 0;
        int y = 0;
        int k = 0;
        int flag = 0;
        s_event_t *event;

	s_thread_mutex_lock(lxynth_root->eventq->mut);
        while (!s_list_eol(lxynth_root->eventq->list, 0)) {
		event = (s_event_t *) s_list_get(lxynth_root->eventq->list, 0);
		s_list_remove(lxynth_root->eventq->list, 0);
                switch (event->type & EVENT_MASK) {
			case QUIT_EVENT:	break;
			case MOUSE_EVENT:	lxynth_event_parse_mouse(event);	break;
			case KEYBD_EVENT:	lxynth_event_parse_keybd(event);	break;
			case CONFIG_EVENT:	lxynth_event_parse_config(event);	break;
		}
		s_event_uninit(event);
	}
	s_thread_mutex_unlock(lxynth_root->eventq->mut);

        if (lxynth_root->running) {
		lxynth_root->timerid = install_timer(20, lxynth_timer, NULL);
	}
}
Beispiel #10
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;
}
Beispiel #11
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;
}
Beispiel #12
0
/**
 * \brief Set window effects
 *
 * Specifies the type of window opening and closing effects. Can also disable
 * effects completely.
 *
 * \param openEffect Sets the window opening effect, slide-in animations are
 * currently supported.
 * \param closeEffect Sets the window closing effect, slide-out animations are
 * currently supported.
 */
void GuiEffectWindow::setEffects(OPEN_EFFECT_TYPE openEffect, CLOSE_EFFECT_TYPE closeEffect)
{
	s_thread_mutex_lock(effectMutex);

	openEffectType = openEffect;
	closeEffectType = closeEffect;

	s_thread_mutex_unlock(effectMutex);
}
Beispiel #13
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);
}
Beispiel #14
0
/**
 * \brief Set effect speed
 *
 * Updates the speed of window effects or animations in both vertical and
 * horizontal direction.
 *
 * \param vertSpeed Specifies the step of a vertical slide animation,
 * in pixels
 * \param horzSpeed Specifies the step of a horizontal slide animation,
 * in pixels
 */
void GuiEffectWindow::setEffectSpeed(int vertSpeed, int horzSpeed)
{
	s_thread_mutex_lock(effectMutex);

	effectVertSpeed = vertSpeed;
	effectHorzSpeed = horzSpeed;

	s_thread_mutex_unlock(effectMutex);
}
Beispiel #15
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;
}
Beispiel #16
0
int s_eventq_add (s_window_t *window, s_event_t *event)
{
        int ret;
	s_thread_mutex_lock(window->eventq->mut);
	event->window = window;
	ret = s_list_add(window->eventq->queue, event, -1);
	s_thread_cond_signal(window->eventq->cond);
	s_thread_mutex_unlock(window->eventq->mut);
	return ret;
}
Beispiel #17
0
s_thread_t * s_thread_create (void * (*f) (void *), void *farg)
{
	s_thread_t *tid;
	s_thread_arg_t *arg;

	if ((s_thread_api == NULL) ||
	    (s_thread_api->thread_create == NULL)) {
		return NULL;
	}

	tid = (s_thread_t *) s_malloc(sizeof(s_thread_t));
	arg = (s_thread_arg_t *) s_malloc(sizeof(s_thread_arg_t));

	arg->r = &s_thread_run;
	arg->f = f;
	arg->arg = farg;
	s_thread_cond_init(&arg->cond);
	s_thread_mutex_init(&arg->mut);

	s_thread_mutex_lock(arg->mut);
	arg->flag = 0;
	s_thread_cond_signal(arg->cond);
	s_thread_mutex_unlock(arg->mut);

	s_thread_api->thread_create(tid, arg);

	s_thread_mutex_lock(arg->mut);
	while (arg->flag != 1) 
	{
		if (s_thread_cond_wait(arg->cond, arg->mut)) {
			debugf(DSYS, "s_thread_cond_wait failed");
			return NULL;
		}
	}
	s_thread_mutex_unlock(arg->mut);

	s_thread_cond_destroy(arg->cond);
	s_thread_mutex_destroy(arg->mut);
	s_free(arg);
	arg = NULL;

	return tid;
}
Beispiel #18
0
static void lxynth_set_title (struct graphics_device *dev, unsigned char *title)
{
	lxynth_device_t *wd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	wd = (lxynth_device_t *) dev->driver_data;
        s_free(wd->title);
        wd->title = strdup(title);

        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}

	s_window_set_title(lxynth_root->window, title);

	s_thread_mutex_unlock(lxynth_root->gd->mut);
}
Beispiel #19
0
static void lxynth_draw_vline (struct graphics_device *dev, int x, int top, int bottom, long color)
{
	lxynth_device_t *wd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	VLINE_CLIP_PREFACE;

        if (lxynth_root->running == 0) return;
        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}

	wd = (lxynth_device_t *) dev->driver_data;
	s_vline(wd->surface, x, top, bottom, color);
	lxynth_surface_update(dev, x, top, 1, bottom - top);
	s_thread_mutex_unlock(lxynth_root->gd->mut);
}
Beispiel #20
0
static void lxynth_draw_hline (struct graphics_device *dev, int left, int y, int right, long color)
{
	lxynth_device_t *wd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	HLINE_CLIP_PREFACE;

        if (lxynth_root->running == 0) return;
        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}

	wd = (lxynth_device_t *) dev->driver_data;
	s_hline(wd->surface, left, y, right, color);
	lxynth_surface_update(dev, left, y, right - left, 1);
	s_thread_mutex_unlock(lxynth_root->gd->mut);
}
Beispiel #21
0
static void lxynth_fill_area (struct graphics_device *dev, int left, int top, int right, int bottom, long color)
{
	lxynth_device_t *wd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	FILL_CLIP_PREFACE;

        if (lxynth_root->running == 0) return;
        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}

	wd = (lxynth_device_t *) dev->driver_data;
	s_fillbox(wd->surface, left, top, right - left, bottom - top, color);
	lxynth_surface_update(dev, left, top, right - left, bottom - top);
	s_thread_mutex_unlock(lxynth_root->gd->mut);
}
Beispiel #22
0
static void lxynth_draw_bitmap (struct graphics_device *dev, struct bitmap *hndl, int x, int y)
{
	lxynth_device_t *wd;
	int xs = hndl->x;
	int ys = hndl->y;
	char *data = hndl->data;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	CLIP_PREFACE;

        if (lxynth_root->running == 0) return;
        s_thread_mutex_lock(lxynth_root->gd->mut);
        if (lxynth_root->gd->active != dev) {
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		return;
	}

	wd = (lxynth_device_t *) dev->driver_data;
        s_putboxpart(wd->surface, x, y, xs, ys, hndl->x, hndl->y, data, 0, 0);
	lxynth_surface_update(dev, x, y, xs, ys);
	s_thread_mutex_unlock(lxynth_root->gd->mut);
}
Beispiel #23
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;
}
Beispiel #24
0
static void lxynth_atexit (s_window_t *window)
{
        if (lxynth_root == NULL) {
		return;
	}
	if (lxynth_root->running) {
		struct graphics_device *gd = lxynth_root->gd->active;

		s_thread_mutex_lock(lxynth_root->gd->mut);
		lxynth_root->running = 0;
		lxynth_root->gd->active = NULL;
		s_thread_mutex_unlock(lxynth_root->gd->mut);
		gd->keyboard_handler(gd, KBD_CLOSE, 0);
	}
}
Beispiel #25
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;
}
Beispiel #26
0
static void * s_thread_run (void *farg)
{
	s_thread_arg_t *arg = (s_thread_arg_t *) farg;
	void *p = arg->arg;
	void * (*f) (void *) = arg->f;

	s_thread_mutex_lock(arg->mut);
	arg->flag = 1;
	s_thread_cond_signal(arg->cond);
	s_thread_mutex_unlock(arg->mut);

	f(p);

	return NULL;
}
Beispiel #27
0
int s_event_parse_keybd_handler (s_window_t *window, s_event_t *event, s_handler_t *work)
{
	if (((work->keybd.flag & event->keybd->flag) == (event->keybd->flag & ~KEYBD_MASL)) &&
	    !(work->keybd.flag & ~event->keybd->flag) &&
	     (event->keybd->button == work->keybd.button)) {
		if (event->type & KEYBD_PRESSED) {
			if (work->keybd.p != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->keybd.p(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			return 0;
		}
		if (event->type & KEYBD_RELEASED) {
			if (work->keybd.r != NULL) {
				s_thread_mutex_unlock(window->handlers->mut);
				work->keybd.r(window, event, work);
				s_thread_mutex_lock(window->handlers->mut);
			}
			return 0;
		}
	}
	return -1;
}
Beispiel #28
0
static void lxynth_shutdown_device (struct graphics_device *dev)
{
        int acc = 0;
        int pos = 0;
	lxynth_device_t *wd;
	struct graphics_device *gd;

	DEBUGF ("%s (%s:%d)\n", __FUNCTION__, __FILE__, __LINE__);

	s_thread_mutex_lock(lxynth_root->gd->mut);
	while (!s_list_eol(lxynth_root->gd->list, pos)) {
		gd = (struct graphics_device *) s_list_get(lxynth_root->gd->list, pos);
		if (gd == dev) {
			s_list_remove(lxynth_root->gd->list, pos);
			if (lxynth_root->gd->list->nb_elt > 0) {
				lxynth_root->gd->active = (struct graphics_device *) s_list_get(lxynth_root->gd->list, 0);
				acc = 1;
			} else {
				lxynth_root->gd->active = NULL;
			}
			break;
		}
		pos++;
	}
	unregister_bottom_half(lxynth_surface_register_update, dev);
	wd = (lxynth_device_t *) dev->driver_data;
	s_free(wd->title);
	s_surface_destroy(wd->surface);
	s_free(wd);
	s_free(dev);
	s_thread_mutex_unlock(lxynth_root->gd->mut);

	if (acc && lxynth_root->running) {
		char *title;
		struct rect r;
		r.x1 = 0;
		r.y1 = 0;
		r.x2 = lxynth_root->window->surface->buf->w;
		r.y2 = lxynth_root->window->surface->buf->h;
		title = strdup(((lxynth_device_t *) lxynth_root->gd->active->driver_data)->title);
		lxynth_set_title(lxynth_root->gd->active, title);
		lxynth_root->gd->active->resize_handler(lxynth_root->gd->active);
		lxynth_root->gd->active->redraw_handler(lxynth_root->gd->active, &r);
		s_free(title);
	}
}
Beispiel #29
0
int s_handlers_uninit (s_window_t *window)
{
	s_handler_t *hndl;

	s_thread_mutex_lock(window->handlers->mut);
	while (!s_list_eol(window->handlers->list, 0)) {
		hndl = (s_handler_t *) s_list_get(window->handlers->list, 0);
		s_list_remove(window->handlers->list, 0);
		s_handler_uninit(hndl);
	}
	s_thread_mutex_unlock(window->handlers->mut);
	s_thread_mutex_destroy(window->handlers->mut);
	s_list_uninit(window->handlers->list);
	s_free(window->handlers);

	return 0;
}
Beispiel #30
0
s_pollfd_t * s_pollfd_find (s_window_t *window, int fd)
{
	int pos;
	s_pollfd_t *pfd;
	s_pollfd_t *ret;
	s_thread_mutex_lock(window->pollfds->mut);
	pos = 0;
	ret = NULL;
	while (!s_list_eol(window->pollfds->list, pos)) {
		pfd = (s_pollfd_t *) s_list_get(window->pollfds->list, pos);
		if (pfd->fd == fd) {
			ret = pfd;
			break;
		}
		pos++;
	}
	s_thread_mutex_unlock(window->pollfds->mut);
	return ret;
}