示例#1
0
文件: editor.c 项目: etrunko/weston
static void
editor_button_handler(struct widget *widget,
		      struct input *input, uint32_t time,
		      uint32_t button,
		      enum wl_pointer_button_state state, void *data)
{
	struct editor *editor = data;

	if (button != BTN_LEFT) {
		return;
	}

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

		text_entry_deactivate(editor->entry, seat);
		text_entry_deactivate(editor->editor, seat);
		editor->active_entry = NULL;
	}
}
示例#2
0
文件: editor.c 项目: Blei/weston
static void
button_handler(struct widget *widget,
	       struct input *input, uint32_t time,
	       uint32_t button,
	       enum wl_pointer_button_state state, void *data)
{
	struct editor *editor = data;
	struct rectangle allocation;
	int32_t x, y;
	struct wl_seat *seat;

	if (state != WL_POINTER_BUTTON_STATE_PRESSED || button != BTN_LEFT) {
		return;
	}

	input_get_position(input, &x, &y);

	widget_get_allocation(editor->widget, &allocation);
	x -= allocation.x;
	y -= allocation.y;

	int32_t activate_entry = rectangle_contains(&editor->entry->allocation, x, y);
	int32_t activate_editor = rectangle_contains(&editor->editor->allocation, x, y);
	assert(!(activate_entry && activate_editor));

	seat = input_get_seat(input);

	if (activate_entry) {
		text_entry_activate(editor->entry, seat);
	} else if (activate_editor) {
		text_entry_activate(editor->editor, seat);
	} else {
		text_entry_deactivate(editor->entry, seat);
		text_entry_deactivate(editor->editor, seat);
	}

	widget_schedule_redraw(widget);
}