Beispiel #1
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym, enum wl_keyboard_key_state state,
	    void *data)
{
	struct image *image = data;

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	switch (sym) {
	case XKB_KEY_minus:
		zoom(image, 0.8);
		window_schedule_redraw(image->window);
		break;
	case XKB_KEY_equal:
	case XKB_KEY_plus:
		zoom(image, 1.2);
		window_schedule_redraw(image->window);
		break;
	case XKB_KEY_1:
		image->matrix.xx = 1.0;
		image->matrix.xy = 0.0;
		image->matrix.yx = 0.0;
		image->matrix.yy = 1.0;
		clamp_view(image);
		window_schedule_redraw(image->window);
		break;
	}
}
Beispiel #2
0
/* ...process new input buffer submitted from camera */
static int sview_input_process(void *data, int i, GstBuffer *buffer)
{
    app_data_t     *app = data;

    BUG(i >= CAMERAS_NUMBER, _x("invalid camera index: %d"), i);

    TRACE(DEBUG, _b("camera-%d: input buffer received"), i);

    /* ...get queue access lock */
    pthread_mutex_lock(&app->lock);

    /* ...check if playback is enabled */
    if ((app->flags & APP_FLAG_EOS) == 0)
    {
        /* ...place buffer into main rendering queue (take ownership) */
        g_queue_push_tail(&app->render[i], buffer), gst_buffer_ref(buffer);

        /* ...indicate buffer is available */
        app->frames &= ~(1 << i);
        
        /* ...schedule processing if all buffers are ready */
        if ((app->frames & ((1 << CAMERAS_NUMBER) - 1)) == 0)
        {
            /* ...all buffers available; trigger surround-view scene processing */
            window_schedule_redraw(app->window);
        }
    }

    /* ...release queue access lock */
    pthread_mutex_unlock(&app->lock);

    return 0;
}
Beispiel #3
0
static void
keyboard_focus_handler(struct window *window,
		       struct input *device, void *data)
{
	struct view *view = data;
	window_schedule_redraw(view->window);
}
Beispiel #4
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym,
	    enum wl_keyboard_key_state state, void *data)
{
	struct demoapp *app = data;
	struct rectangle winrect;

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	switch (sym) {
	case XKB_KEY_space:
		app->animate = !app->animate;
		window_schedule_redraw(window);
		break;
	case XKB_KEY_Up:
		window_get_allocation(window, &winrect);
		winrect.height -= 100;
		if (winrect.height < 150)
			winrect.height = 150;
		window_schedule_resize(window, winrect.width, winrect.height);
		break;
	case XKB_KEY_Down:
		window_get_allocation(window, &winrect);
		winrect.height += 100;
		if (winrect.height > 600)
			winrect.height = 600;
		window_schedule_resize(window, winrect.width, winrect.height);
		break;
	case XKB_KEY_Escape:
		display_exit(app->display);
		break;
	}
}
Beispiel #5
0
static void
frame_callback(void *data, uint32_t time)
{
	struct resizor *resizor = data;
	double force, height;

	height = resizor->height.current;
	force = (resizor->height.target - height) / 10.0 +
		(resizor->height.previous - height);

	resizor->height.current =
		height + (height - resizor->height.previous) + force;
	resizor->height.previous = height;

	if (resizor->height.current >= 400) {
		resizor->height.current = 400;
		resizor->height.previous = 400;
	}

	if (resizor->height.current <= 200) {
		resizor->height.current = 200;
		resizor->height.previous = 200;
	}

	window_set_child_size(resizor->window, resizor->width, height + 0.5);

	window_schedule_redraw(resizor->window);
}
Beispiel #6
0
static void
keyboard_focus_handler(struct window *window,
		       struct input *device, void *data)
{
	struct resizor *resizor = data;

	window_schedule_redraw(resizor->window);
}
Beispiel #7
0
static void
keyboard_focus_handler(struct window *window,
		       struct input *device, void *data)
{
	struct demoapp *app = data;

	window_schedule_redraw(app->window);
}
Beispiel #8
0
static void
keyboard_focus_handler(struct window *window,
		       struct input *device, void *data)
{
	struct cliptest *cliptest = data;

	window_schedule_redraw(cliptest->window);
}
Beispiel #9
0
static void
keyboard_focus_handler(struct window *window,
		       struct input *device, void *data)
{
	struct image *image = data;

	window_schedule_redraw(image->window);
}
Beispiel #10
0
static void
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
{
	struct ModeInfo *mi = data;

	window_schedule_redraw(mi->window);
	wl_callback_destroy(callback);
}
Beispiel #11
0
static void
view_page_up(struct view *view)
{
        if(view->page <= 0)
                return;

        view->page--;
        window_schedule_redraw(view->window);
}
Beispiel #12
0
static void
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
{
	struct smoke *smoke = data;

	window_schedule_redraw(smoke->window);
	smoke->time = time;

	if (callback)
		wl_callback_destroy(callback);
}
Beispiel #13
0
static void
view_page_down(struct view *view)
{
        if(!view->document ||
           view->page >= poppler_document_get_n_pages(view->document) - 1) {
                return;
        }

        view->page++;
        window_schedule_redraw(view->window);
}
Beispiel #14
0
static void
output_handler(struct window *window, struct output *output, int enter,
	       void *data)
{
	if (!enter)
		return;

	window_set_buffer_transform(window, output_get_transform(output));
	window_set_buffer_scale(window, output_get_scale(output));
	window_schedule_redraw(window);
}
Beispiel #15
0
static void
frame_callback(struct wl_surface *surface, void *data, uint32_t time)
{
	struct gears *gears = data;

	gears->angle = (GLfloat) (time % 8192) * 360 / 8192.0;

	window_schedule_redraw(gears->window);
	wl_display_frame_callback(display_get_display(gears->d),
				  window_get_wl_surface(gears->window),
				  frame_callback, gears);
}
Beispiel #16
0
static void
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
{
	struct gears *gears = data;

	gears->angle = (GLfloat) (time % 8192) * 360 / 8192.0;

	window_schedule_redraw(gears->window);

	if (callback)
		wl_callback_destroy(callback);
}
Beispiel #17
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym, enum wl_keyboard_key_state state,
	    void *data)
{
	int transform, scale;

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	transform = window_get_buffer_transform (window);
	scale = window_get_buffer_scale (window);
	switch (sym) {
	case XKB_KEY_Left:
		if (transform == 0)
			transform = 3;
		else if (transform == 4)
			transform = 7;
		else
			transform--;
		break;

	case XKB_KEY_Right:
		if (transform == 3)
			transform = 0;
		else if (transform == 7)
			transform = 4;
		else
			transform++;
		break;

	case XKB_KEY_space:
		if (transform >= 4)
			transform -= 4;
		else
			transform += 4;
		break;

	case XKB_KEY_z:
		if (scale == 1)
			scale = 2;
		else
			scale = 1;
		break;
	}

	printf ("setting buffer transform to %d\n", transform);
	printf ("setting buffer scale to %d\n", scale);
	window_set_buffer_transform(window, transform);
	window_set_buffer_scale(window, scale);
	window_schedule_redraw(window);
}
Beispiel #18
0
static void
frame_callback(void *data, uint32_t time)
{
	struct gears *gears = data;

	gears->current = 1 - gears->current;

	gears->angle = (GLfloat) (time % 8192) * 360 / 8192.0;

	window_schedule_redraw(gears->window);
	wl_display_frame_callback(display_get_display(gears->d),
				  frame_callback, gears);
}
Beispiel #19
0
static int
motion_handler(struct widget *widget,
	       struct input *input, uint32_t time,
	       float x, float y, void *data)
{
	struct clickdot *clickdot = data;
	clickdot->line.x = x;
	clickdot->line.y = y;

	window_schedule_redraw(clickdot->window);

	return CURSOR_LEFT_PTR;
}
Beispiel #20
0
static void
move_viewport(struct image *image, double dx, double dy)
{
	double scale = get_scale(image);

	if (!image->initialized)
		return;

	cairo_matrix_translate(&image->matrix, -dx/scale, -dy/scale);
	clamp_view(image);

	window_schedule_redraw(image->window);
}
Beispiel #21
0
static int
motion_handler(struct widget *widget,
	       struct input *input, uint32_t time,
	       float x, float y, void *data)
{
	struct clickdot *clickdot = data;
	clickdot->line.x = x;
	clickdot->line.y = y;

	window_schedule_redraw(clickdot->window);

	cursor_timeout_reset(clickdot);
	clickdot->cursor_timeout_input = input;

	return CURSOR_BLANK;
}
Beispiel #22
0
static void
handle_configure(void *data, struct wl_shell *shell,
		 uint32_t time, uint32_t edges,
		 struct wl_surface *surface, int32_t width, int32_t height)
{
	struct window *window = wl_surface_get_user_data(surface);

	window->resize_edges = edges;
	window->allocation.width = width;
	window->allocation.height = height;

	if (window->resize_handler)
		(*window->resize_handler)(window, window->user_data);
	if (window->redraw_handler)
		window_schedule_redraw(window);
}
Beispiel #23
0
/**
 * \brief CALLBACK function, Wayland informs about keyboard focus change
 * \param window window
 * \param device device that caused the focus change
 * \param data user data associated to the window
 */
static void
keyboard_focus_handler(struct window *window,
		       struct input *device, void *data)
{
	int32_t x, y;
	struct eventdemo *e = data;

	if (log_focus) {
		if (device) {
			input_get_position(device, &x, &y);
			printf("focus x: %d, y: %d\n", x, y);
		} else {
			printf("focus lost\n");
		}
	}

	window_schedule_redraw(e->window);
}
Beispiel #24
0
static void
axis_handler(struct widget *widget, struct input *input, uint32_t time,
	     uint32_t axis, wl_fixed_t value, void *data)
{
	struct image *image = data;

	if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL &&
	    input_get_modifiers(input) == MOD_CONTROL_MASK) {
		/* set zoom level to 2% per 10 axis units */
		zoom(image, (1.0 - wl_fixed_to_double(value) / 500.0));

		window_schedule_redraw(image->window);
	} else if (input_get_modifiers(input) == 0) {
		if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
			move_viewport(image, 0, wl_fixed_to_double(value));
		else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
			move_viewport(image, wl_fixed_to_double(value), 0);
	}
}
Beispiel #25
0
static void
handle_configure(void *data, struct wl_shell *shell,
		 uint32_t time, uint32_t edges,
		 struct wl_surface *surface, int32_t width, int32_t height)
{
	struct window *window = wl_surface_get_user_data(surface);
	int32_t child_width, child_height;

	if (window->resize_handler) {
		child_width = width - 20 - window->margin * 2;
		child_height = height - 60 - window->margin * 2;

		(*window->resize_handler)(window,
					  child_width, child_height,
					  window->user_data);
	} else {
		window->resize_edges = edges;
		window->allocation.width = width;
		window->allocation.height = height;

		if (window->redraw_handler)
			window_schedule_redraw(window);
	}
}
Beispiel #26
0
/* ...push buffer into object-detection library */
static void __objdet_buffer_ready(void *cdata, void *cookie, road_scene_t *scene)
{
    app_data_t     *app = cdata;
    GstBuffer      *buffer = cookie;
    GQueue         *queue = &app->render[CAMERAS_NUMBER];
    
    TRACE(DEBUG, _b("buffer returned from engine: %p"), buffer);

    /* ...get internal data lock */
    pthread_mutex_lock(&app->lock);

    /* ...check if visualization is still enabled */
    if ((app->flags & APP_FLAG_EOS) == 0)
    {
        /* ...submit buffer to a rendering queue (take the ownership) */
        g_queue_push_tail(queue, buffer), gst_buffer_ref(buffer);

        /* ...schedule rendering operation */
        window_schedule_redraw(app->window);
    }

    /* ...release internal data access lock */
    pthread_mutex_unlock(&app->lock);
}
Beispiel #27
0
static void
keyboard_focus_handler(struct window *window,
		       struct input *device, void *data)
{
	window_schedule_redraw(window);
}
Beispiel #28
0
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t sym, enum wl_keyboard_key_state state,
	    void *data)
{
	struct fullscreen *fullscreen = data;
	int transform, scale;
	static int current_size = 0;
	struct fs_output *fsout;
	struct wl_output *wl_output;
	int widths[] = { 640, 320, 800, 400 };
	int heights[] = { 480, 240, 600, 300 };

	if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
		return;

	switch (sym) {
	case XKB_KEY_t:
		transform = window_get_buffer_transform (window);
		transform = (transform + 1) % 8;
		window_set_buffer_transform(window, transform);
		window_schedule_redraw(window);
		break;

	case XKB_KEY_s:
		scale = window_get_buffer_scale (window);
		if (scale == 1)
			scale = 2;
		else
			scale = 1;
		window_set_buffer_scale(window, scale);
		window_schedule_redraw(window);
		break;

	case XKB_KEY_z:
		current_size = (current_size + 1) % 4;
		fullscreen->width = widths[current_size];
		fullscreen->height = heights[current_size];
		window_schedule_resize(fullscreen->window,
				       fullscreen->width, fullscreen->height);
		break;

	case XKB_KEY_m:
		if (!fullscreen->fshell)
			break;

		wl_output = NULL;
		if (fullscreen->current_output)
			wl_output = output_get_wl_output(fullscreen->current_output->output);
		fullscreen->present_method = (fullscreen->present_method + 1) % 5;
		_wl_fullscreen_shell_present_surface(fullscreen->fshell,
						     window_get_wl_surface(fullscreen->window),
						     fullscreen->present_method,
						     wl_output);
		window_schedule_redraw(window);
		break;

	case XKB_KEY_o:
		if (!fullscreen->fshell)
			break;

		fsout = fullscreen->current_output;
		wl_output = fsout ? output_get_wl_output(fsout->output) : NULL;

		/* Clear the current presentation */
		_wl_fullscreen_shell_present_surface(fullscreen->fshell, NULL,
						     0, wl_output);

		if (fullscreen->current_output) {
			if (fullscreen->current_output->link.next == &fullscreen->output_list)
				fsout = NULL;
			else
				fsout = wl_container_of(fullscreen->current_output->link.next,
							fsout, link);
		} else {
			fsout = wl_container_of(fullscreen->output_list.next,
						fsout, link);
		}

		fullscreen->current_output = fsout;
		wl_output = fsout ? output_get_wl_output(fsout->output) : NULL;
		_wl_fullscreen_shell_present_surface(fullscreen->fshell,
						     window_get_wl_surface(fullscreen->window),
						     fullscreen->present_method,
						     wl_output);
		window_schedule_redraw(window);
		break;

	case XKB_KEY_w:
		if (!fullscreen->fshell || !fullscreen->current_output)
			break;

		wl_output = NULL;
		if (fullscreen->current_output)
			wl_output = output_get_wl_output(fullscreen->current_output->output);
		_wl_fullscreen_shell_mode_feedback_destroy(
			_wl_fullscreen_shell_present_surface_for_mode(fullscreen->fshell,
								      window_get_wl_surface(fullscreen->window),
								      wl_output, 0));
		window_schedule_redraw(window);
		break;

	case XKB_KEY_f:
		if (fullscreen->fshell)
			break;
		fullscreen->fullscreen ^= 1;
		window_set_fullscreen(window, fullscreen->fullscreen);
		break;

	case XKB_KEY_q:
		exit (0);
		break;
	}
}