Exemple #1
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;
	}
}
Exemple #2
0
int s_event_copy (s_event_t *event, s_event_t **nevent)
{
	s_event_t *tmp;
	if (s_event_init(&tmp)) {
		return -1;
	}
	tmp->type = event->type;
	memcpy(tmp->mouse, event->mouse, sizeof(s_mouse_t));
	memcpy(tmp->keybd, event->keybd, sizeof(s_keybd_t));
	memcpy(tmp->expose->rect, event->expose->rect, sizeof(s_rect_t));
	*nevent = tmp;
	return 0;
}
Exemple #3
0
static void handler_set_char (s_window_t *window, osk_char_t *chr)
{
    s_event_t *evt;
    s_event_init(&evt);
    evt->type = KEYBD_EVENT | KEYBD_PRESSED;
    evt->keybd->ascii = chr->ascii;
    evt->keybd->button = chr->button;
    evt->keybd->keycode = chr->button;
    evt->keybd->scancode = chr->scancode;
    s_socket_request(window, SOC_DATA_EVENT, evt);
    evt->type = KEYBD_EVENT | KEYBD_RELEASED;
    s_socket_request(window, SOC_DATA_EVENT, evt);
    s_event_uninit(evt);
}
Exemple #4
0
void w_signal_send (w_object_t *from, w_object_t *to, void (*func) (w_signal_t *), void *arg)
{
	s_event_t *event;
	w_signal_t *signal;
	s_event_init(&event);
	event->type = SIGNAL_EVENT;
	signal = (w_signal_t *) s_malloc(sizeof(w_signal_t));
	signal->from = from;
	signal->to  = to;
	signal->func = func;
	signal->arg = arg;
	event->data = (void *) signal;
	s_eventq_add(to->window->window, event);
}
Exemple #5
0
int s_window_init (s_window_t **window)
{
	s_window_t *w;

	w = (s_window_t *) s_calloc(1, sizeof(s_window_t));
	if (s_pollfds_init(w))       { goto err1; }
	if (s_timers_init(w))        { goto err2; }
	if (s_socket_init(w))        { goto err3; }
        if (s_handlers_init(w))      { goto err4; }
	if (s_childs_init(w))        { goto err5; }
	if (s_eventq_init(w))        { goto err6; }
	if (s_event_init(&w->event)) { goto err7; }

	w->running = 1;
	w->id = -1;
	w->pri = -1;
	w->mapped = -1;
	w->viewable = -1;
	w->resizeable = 1;
	w->alwaysontop = 0;
	w->cursor = CURSOR_TYPE_ARROW;
	w->mouse_entered = 0;
	*window = w;

	if (s_surface_init(w))                     { goto err8; }
	if (s_socket_request(w, SOC_DATA_DISPLAY)) { goto err9; }
	if (s_surface_attach(w))                   { goto err10; }

	return 0;
err10:
err9:	s_surface_uninit(w);
err8:	s_event_uninit(w->event);
err7:	s_eventq_uninit(w);
err6:	s_childs_uninit(w);
err5:	s_handlers_uninit(w);
err4:
err3:	s_timers_uninit(w);
err2:	s_pollfds_uninit(w);
err1:	s_free(w);
	debugf(DCLI | DFAT, "Cannot connect to server");
	return -1;
}
Exemple #6
0
int s_window_init (s_window_t **window)
{
    s_window_t *w;

    w = (s_window_t *) s_calloc(1, sizeof(s_window_t));
    if (s_surface_init(w))       {
        goto err1;
    }
    if (s_pollfds_init(w))       {
        goto err2;
    }
    if (s_timers_init(w))        {
        goto err3;
    }
    if (s_socket_init(w))        {
        goto err4;
    }
    if (s_handlers_init(w))      {
        goto err4;
    }
    if (s_childs_init(w))        {
        goto err5;
    }
    if (s_eventq_init(w))        {
        goto err6;
    }
    if (s_event_init(&w->event)) {
        goto err7;
    }
    if (s_gettext_init(w))       {
        goto err8;
    }

    w->running = 1;
    w->id = -1;
    w->pri = -1;
    w->resizeable = 1;

    /* -1 means no limits on width or height. */
    w->min_w = w->min_h = w->max_w = w->max_h = -1;

    w->alwaysontop = 0;
    w->cursor = MOUSE_CURSOR_ARROW;
    w->mouse_entered = 0;
    *window = w;

    if (s_socket_request(w, SOC_DATA_DISPLAY)) {
        goto err9;
    }

    return 0;
err9:
    s_gettext_uninit(w);
err8:
    s_event_uninit(w->event);
err7:
    s_eventq_uninit(w);
err6:
    s_childs_uninit(w);
err5:
    s_handlers_uninit(w);
err4:
    s_timers_uninit(w);
err3:
    s_pollfds_uninit(w);
err2:
    s_free(w->surface);
err1:
    s_free(w);
    debugf(DCLI | DFAT, "Cannot connect to server");
    return -1;
}