If the mouse is not moved during a mouse-click, then we clear the current
selection. This can be increased to allow a short range of few pixels of
mouse-movement if required.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
int pointer_x;
int pointer_y;
bool in_selection;
int pointer_x;
int pointer_y;
bool in_selection;
+ bool selection_started;
+ int sel_start_x;
+ int sel_start_y;
};
static int draw_cell(struct tsm_screen *scr,
};
static int draw_cell(struct tsm_screen *scr,
term->pointer_x = -1;
term->pointer_y = -1;
return;
term->pointer_x = -1;
term->pointer_y = -1;
return;
+ } else if (term->pointer_x == x - term->alloc.x &&
+ term->pointer_y == y - term->alloc.y) {
+ return;
} else {
term->pointer_x = x - term->alloc.x;
term->pointer_y = y - term->alloc.y;
}
} else {
term->pointer_x = x - term->alloc.x;
term->pointer_y = y - term->alloc.y;
}
- posx = term->pointer_x / term->font_normal->attr.width;
- posy = term->pointer_y / term->font_normal->attr.height;
-
if (term->in_selection) {
if (term->in_selection) {
- tsm_screen_selection_target(term->scr, posx, posy);
+ if (!term->selection_started) {
+ term->selection_started = true;
+ posx = term->sel_start_x / term->font_normal->attr.width;
+ posy = term->sel_start_y / term->font_normal->attr.height;
+
+ tsm_screen_selection_start(term->scr, posx, posy);
+ } else {
+ posx = term->pointer_x / term->font_normal->attr.width;
+ posy = term->pointer_y / term->font_normal->attr.height;
+
+ tsm_screen_selection_target(term->scr, posx, posy);
+ }
+
wlt_window_schedule_redraw(term->wnd);
}
}
wlt_window_schedule_redraw(term->wnd);
}
}
uint32_t button, uint32_t state, void *data)
{
struct wlt_terminal *term = data;
uint32_t button, uint32_t state, void *data)
{
struct wlt_terminal *term = data;
- unsigned int posx, posy;
if (button != BTN_LEFT)
return;
if (button != BTN_LEFT)
return;
if (!term->in_selection &&
term->pointer_x >= 0 && term->pointer_y >= 0) {
term->in_selection = true;
if (!term->in_selection &&
term->pointer_x >= 0 && term->pointer_y >= 0) {
term->in_selection = true;
+ term->selection_started = false;
- posx = term->pointer_x / term->font_normal->attr.width;
- posy = term->pointer_y / term->font_normal->attr.height;
-
- tsm_screen_selection_start(term->scr, posx, posy);
- wlt_window_schedule_redraw(term->wnd);
+ term->sel_start_x = term->pointer_x;
+ term->sel_start_y = term->pointer_y;
+ if (term->pointer_x == term->sel_start_x &&
+ term->pointer_y == term->sel_start_y) {
+ tsm_screen_selection_reset(term->scr);
+ wlt_window_schedule_redraw(term->wnd);
+ }
+
term->in_selection = false;
}
}
term->in_selection = false;
}
}