Esempio n. 1
0
static int
text_entry_motion_handler(struct widget *widget,
			  struct input *input, uint32_t time,
			  float x, float y, void *data)
{
	struct text_entry *entry = data;
	struct rectangle allocation;

	widget_get_allocation(entry->widget, &allocation);

	text_entry_set_cursor_position(entry,
				       x - allocation.x - text_offset_left,
				       y - allocation.y - text_offset_left);

	return CURSOR_IBEAM;
}
Esempio n. 2
0
static void
text_entry_button_handler(struct widget *widget,
			  struct input *input, uint32_t time,
			  uint32_t button,
			  enum wl_pointer_button_state state, void *data)
{
	struct text_entry *entry = data;
	struct rectangle allocation;
	struct editor *editor;
	int32_t x, y;
	uint32_t result;

	widget_get_allocation(entry->widget, &allocation);
	input_get_position(input, &x, &y);

	x -= allocation.x + text_offset_left;
	y -= allocation.y + text_offset_left;

	editor = window_get_user_data(entry->window);

	if (button == BTN_LEFT) {
		entry->button_pressed = (state == WL_POINTER_BUTTON_STATE_PRESSED);

		if (state == WL_POINTER_BUTTON_STATE_PRESSED)
			input_grab(input, entry->widget, button);
		else
			input_ungrab(input);
	}

	if (text_entry_has_preedit(entry)) {
		result = text_entry_try_invoke_preedit_action(entry, x, y, button, state);

		if (result)
			return;
	}

	if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
		struct wl_seat *seat = input_get_seat(input);

		text_entry_activate(entry, seat);
		editor->active_entry = entry;

		text_entry_set_cursor_position(entry, x, y, true);
	}
}
Esempio n. 3
0
static void
text_entry_button_handler(struct widget *widget,
			  struct input *input, uint32_t time,
			  uint32_t button,
			  enum wl_pointer_button_state state, void *data)
{
	struct text_entry *entry = data;
	struct rectangle allocation;
	struct editor *editor;
	int32_t x, y;

	widget_get_allocation(entry->widget, &allocation);
	input_get_position(input, &x, &y);

	editor = window_get_user_data(entry->window);

	if (button != BTN_LEFT) {
		return;
	}

	text_entry_set_cursor_position(entry,
				       x - allocation.x - text_offset_left,
				       y - allocation.y - text_offset_left);

	if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
		struct wl_seat *seat = input_get_seat(input);

		text_entry_activate(entry, seat);
		editor->active_entry = entry;

		text_entry_set_anchor_position(entry,
					       x - allocation.x - text_offset_left,
					       y - allocation.y - text_offset_left);

		widget_set_motion_handler(entry->widget, text_entry_motion_handler);
	} else {
		widget_set_motion_handler(entry->widget, NULL);
	}
}