|
|
@ -467,7 +467,7 @@ struct terminal { |
|
|
|
uint32_t hide_cursor_serial; |
|
|
|
uint32_t hide_cursor_serial; |
|
|
|
|
|
|
|
|
|
|
|
struct wl_data_source *selection; |
|
|
|
struct wl_data_source *selection; |
|
|
|
uint32_t button_time; |
|
|
|
uint32_t click_time; |
|
|
|
int dragging, click_count; |
|
|
|
int dragging, click_count; |
|
|
|
int selection_start_x, selection_start_y; |
|
|
|
int selection_start_x, selection_start_y; |
|
|
|
int selection_end_x, selection_end_y; |
|
|
|
int selection_end_x, selection_end_y; |
|
|
@ -2687,6 +2687,25 @@ show_menu(struct terminal *terminal, struct input *input, uint32_t time) |
|
|
|
entries, ARRAY_LENGTH(entries)); |
|
|
|
entries, ARRAY_LENGTH(entries)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
click_handler(struct widget *widget, struct terminal *terminal, |
|
|
|
|
|
|
|
struct input *input, int32_t x, int32_t y, |
|
|
|
|
|
|
|
uint32_t time) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (time - terminal->click_time < 500) |
|
|
|
|
|
|
|
terminal->click_count++; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
terminal->click_count = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
terminal->click_time = time; |
|
|
|
|
|
|
|
terminal->dragging = (terminal->click_count - 1) % 3 + SELECT_CHAR; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
terminal->selection_end_x = terminal->selection_start_x = x; |
|
|
|
|
|
|
|
terminal->selection_end_y = terminal->selection_start_y = y; |
|
|
|
|
|
|
|
if (recompute_selection(terminal)) |
|
|
|
|
|
|
|
widget_schedule_redraw(widget); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
button_handler(struct widget *widget, |
|
|
|
button_handler(struct widget *widget, |
|
|
|
struct input *input, uint32_t time, |
|
|
|
struct input *input, uint32_t time, |
|
|
@ -2694,27 +2713,13 @@ button_handler(struct widget *widget, |
|
|
|
enum wl_pointer_button_state state, void *data) |
|
|
|
enum wl_pointer_button_state state, void *data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct terminal *terminal = data; |
|
|
|
struct terminal *terminal = data; |
|
|
|
|
|
|
|
int32_t x, y; |
|
|
|
|
|
|
|
|
|
|
|
switch (button) { |
|
|
|
switch (button) { |
|
|
|
case BTN_LEFT: |
|
|
|
case BTN_LEFT: |
|
|
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED) { |
|
|
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED) { |
|
|
|
|
|
|
|
input_get_position(input, &x, &y); |
|
|
|
if (time - terminal->button_time < 500) |
|
|
|
click_handler(widget, terminal, input, x, y, time); |
|
|
|
terminal->click_count++; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
terminal->click_count = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
terminal->button_time = time; |
|
|
|
|
|
|
|
terminal->dragging = |
|
|
|
|
|
|
|
(terminal->click_count - 1) % 3 + SELECT_CHAR; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
input_get_position(input, |
|
|
|
|
|
|
|
&terminal->selection_start_x, |
|
|
|
|
|
|
|
&terminal->selection_start_y); |
|
|
|
|
|
|
|
terminal->selection_end_x = terminal->selection_start_x; |
|
|
|
|
|
|
|
terminal->selection_end_y = terminal->selection_start_y; |
|
|
|
|
|
|
|
if (recompute_selection(terminal)) |
|
|
|
|
|
|
|
widget_schedule_redraw(widget); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
terminal->dragging = SELECT_NONE; |
|
|
|
terminal->dragging = SELECT_NONE; |
|
|
|
} |
|
|
|
} |
|
|
@ -2768,6 +2773,43 @@ output_handler(struct window *window, struct output *output, int enter, |
|
|
|
window_schedule_redraw(window); |
|
|
|
window_schedule_redraw(window); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
touch_down_handler(struct widget *widget, struct input *input, |
|
|
|
|
|
|
|
uint32_t serial, uint32_t time, int32_t id, |
|
|
|
|
|
|
|
float x, float y, void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct terminal *terminal = data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (id == 0) |
|
|
|
|
|
|
|
click_handler(widget, terminal, input, x, y, time); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
touch_up_handler(struct widget *widget, struct input *input, |
|
|
|
|
|
|
|
uint32_t serial, uint32_t time, int32_t id, void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct terminal *terminal = data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (id == 0) |
|
|
|
|
|
|
|
terminal->dragging = SELECT_NONE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
touch_motion_handler(struct widget *widget, struct input *input, |
|
|
|
|
|
|
|
uint32_t time, int32_t id, float x, float y, void *data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
struct terminal *terminal = data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (terminal->dragging && |
|
|
|
|
|
|
|
id == 0) { |
|
|
|
|
|
|
|
terminal->selection_end_x = (int)x; |
|
|
|
|
|
|
|
terminal->selection_end_y = (int)y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (recompute_selection(terminal)) |
|
|
|
|
|
|
|
widget_schedule_redraw(widget); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifndef howmany |
|
|
|
#ifndef howmany |
|
|
|
#define howmany(x, y) (((x) + ((y) - 1)) / (y)) |
|
|
|
#define howmany(x, y) (((x) + ((y) - 1)) / (y)) |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -2815,6 +2857,9 @@ terminal_create(struct display *display) |
|
|
|
widget_set_button_handler(terminal->widget, button_handler); |
|
|
|
widget_set_button_handler(terminal->widget, button_handler); |
|
|
|
widget_set_enter_handler(terminal->widget, enter_handler); |
|
|
|
widget_set_enter_handler(terminal->widget, enter_handler); |
|
|
|
widget_set_motion_handler(terminal->widget, motion_handler); |
|
|
|
widget_set_motion_handler(terminal->widget, motion_handler); |
|
|
|
|
|
|
|
widget_set_touch_up_handler(terminal->widget, touch_up_handler); |
|
|
|
|
|
|
|
widget_set_touch_down_handler(terminal->widget, touch_down_handler); |
|
|
|
|
|
|
|
widget_set_touch_motion_handler(terminal->widget, touch_motion_handler); |
|
|
|
|
|
|
|
|
|
|
|
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0); |
|
|
|
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0); |
|
|
|
cr = cairo_create(surface); |
|
|
|
cr = cairo_create(surface); |
|
|
|