예제 #1
0
static void
set_pointer_image(struct input *input, uint32_t time, int pointer)
{
	struct display *display = input->display;
	struct wl_buffer *buffer;
	cairo_surface_t *surface;
	int location;

	location = get_pointer_location(input->pointer_focus,
					input->sx, input->sy);
	switch (location) {
	case WINDOW_RESIZING_TOP:
		pointer = POINTER_TOP;
		break;
	case WINDOW_RESIZING_BOTTOM:
		pointer = POINTER_BOTTOM;
		break;
	case WINDOW_RESIZING_LEFT:
		pointer = POINTER_LEFT;
		break;
	case WINDOW_RESIZING_RIGHT:
		pointer = POINTER_RIGHT;
		break;
	case WINDOW_RESIZING_TOP_LEFT:
		pointer = POINTER_TOP_LEFT;
		break;
	case WINDOW_RESIZING_TOP_RIGHT:
		pointer = POINTER_TOP_RIGHT;
		break;
	case WINDOW_RESIZING_BOTTOM_LEFT:
		pointer = POINTER_BOTTOM_LEFT;
		break;
	case WINDOW_RESIZING_BOTTOM_RIGHT:
		pointer = POINTER_BOTTOM_RIGHT;
		break;
	case WINDOW_EXTERIOR:
	case WINDOW_TITLEBAR:
		if (input->current_pointer_image == POINTER_DEFAULT)
			return;

		wl_input_device_attach(input->input_device, time, NULL, 0, 0);
		input->current_pointer_image = POINTER_DEFAULT;
		return;
	default:
		break;
	}

	if (pointer == input->current_pointer_image)
		return;

	input->current_pointer_image = pointer;
	surface = display->pointer_surfaces[pointer];
	buffer = display_get_buffer_for_surface(display, surface);
	wl_input_device_attach(input->input_device, time, buffer,
			       pointer_images[pointer].hotspot_x,
			       pointer_images[pointer].hotspot_y);
}
예제 #2
0
static void
window_handle_button(void *data,
		     struct wl_input_device *input_device,
		     uint32_t time, uint32_t button, uint32_t state)
{
	struct input *input = data;
	struct window *window = input->pointer_focus;
	int location;

	location = get_pointer_location(window, input->sx, input->sy);

	if (button == BTN_LEFT && state == 1) {
		switch (location) {
		case WINDOW_TITLEBAR:
			wl_shell_move(window->display->shell,
				      window->surface, input_device, time);
			break;
		case WINDOW_RESIZING_TOP:
		case WINDOW_RESIZING_BOTTOM:
		case WINDOW_RESIZING_LEFT:
		case WINDOW_RESIZING_RIGHT:
		case WINDOW_RESIZING_TOP_LEFT:
		case WINDOW_RESIZING_TOP_RIGHT:
		case WINDOW_RESIZING_BOTTOM_LEFT:
		case WINDOW_RESIZING_BOTTOM_RIGHT:
			wl_shell_resize(window->display->shell,
					window->surface, input_device, time,
					location);
			break;
		case WINDOW_CLIENT_AREA:
			if (window->button_handler)
				(*window->button_handler)(window,
							  input, time,
							  button, state,
							  window->user_data);
			break;
		}
	} else {
		if (window->button_handler)
			(*window->button_handler)(window,
						  input, time,
						  button, state,
						  window->user_data);
	}
}
예제 #3
0
파일: wlt_theme.c 프로젝트: niterain/kmscon
static void widget_pointer_motion(struct wlt_widget *widget,
				  unsigned int x, unsigned int y, void *data)
{
	struct wlt_theme *theme = data;

	if (!wlt_rect_contains(&theme->alloc, x, y)) {
		set_pointer_location(theme, LOC_NOWHERE);
		return;
	} else {
		theme->pointer_x = x + theme->alloc.x;
		theme->pointer_y = y + theme->alloc.y;
		set_pointer_location(theme, get_pointer_location(theme));
	}

	switch (theme->pointer_loc) {
	case LOC_RESIZE_LEFT:
		wlt_window_set_cursor(theme->wnd, WLT_CURSOR_LEFT);
		break;
	case LOC_RESIZE_RIGHT:
		wlt_window_set_cursor(theme->wnd, WLT_CURSOR_RIGHT);
		break;
	case LOC_RESIZE_TOP:
		wlt_window_set_cursor(theme->wnd, WLT_CURSOR_TOP);
		break;
	case LOC_RESIZE_BOTTOM:
		wlt_window_set_cursor(theme->wnd, WLT_CURSOR_BOTTOM);
		break;
	case LOC_RESIZE_TOP_LEFT:
		wlt_window_set_cursor(theme->wnd, WLT_CURSOR_TOP_LEFT);
		break;
	case LOC_RESIZE_TOP_RIGHT:
		wlt_window_set_cursor(theme->wnd, WLT_CURSOR_TOP_RIGHT);
		break;
	case LOC_RESIZE_BOTTOM_LEFT:
		wlt_window_set_cursor(theme->wnd,
				      WLT_CURSOR_BOTTOM_LEFT);
		break;
	case LOC_RESIZE_BOTTOM_RIGHT:
		wlt_window_set_cursor(theme->wnd,
				      WLT_CURSOR_BOTTOM_RIGHT);
		break;
	default:
		wlt_window_set_cursor(theme->wnd, WLT_CURSOR_LEFT_PTR);
	}
}
예제 #4
0
static void
window_handle_motion(void *data, struct wl_input_device *input_device,
		     uint32_t time,
		     int32_t x, int32_t y, int32_t sx, int32_t sy)
{
	struct input *input = data;
	struct window *window = input->pointer_focus;
	int location, pointer = POINTER_LEFT_PTR;

	input->x = x;
	input->y = y;
	input->sx = sx;
	input->sy = sy;

	location = get_pointer_location(window, input->sx, input->sy);

	if (window->motion_handler)
		pointer = (*window->motion_handler)(window, input, time,
						    x, y, sx, sy,
						    window->user_data);

	set_pointer_image(input, time, pointer);
}