Michael Graczyk
2014-12-09 01:25:29 UTC
On large displays, mouse selection performance was poor. Tmux was
redrawing the entire screen for every mouse coordinate update when it only
needed to update those lines where the selection might have changed.
This patch makes mouse selection buttery-smooth by only updating those
lines that need updating.
Date: Mon, 8 Dec 2014 16:57:49 -0800
Subject: [PATCH] Fix poor performance during mouse mode selection.
---
window-copy.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/window-copy.c b/window-copy.c
index f597332..e7fbd32 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -868,12 +868,37 @@ window_copy_key_numeric_prefix(struct window_pane
*wp, int key)
return (0);
}
+static void
+window_copy_for_selection(
+ struct window_pane *wp,
+ u_int old_x,
+ u_int old_y
+) {
+ struct window_copy_mode_data *data = wp->modedata;
+ const u_int new_y = data->cy;
+ u_int start, end, lines;
+
+ (void)old_x;
+ if (old_y <= new_y) {
+ start = old_y;
+ end = new_y;
+ } else {
+ start = new_y;
+ end = old_y;
+ }
+
+ lines = end - start + 1;
+ window_copy_redraw_lines(wp, start, lines);
+}
+
void
window_copy_mouse(struct window_pane *wp, struct session *sess,
struct mouse_event *m)
{
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
+ u_int old_cx;
+ u_int old_cy;
u_int i;
if (m->x >= screen_size_x(s))
@@ -907,9 +932,11 @@ window_copy_mouse(struct window_pane *wp, struct
session *sess,
*/
if (s->mode & MODE_MOUSE_BUTTON) {
if (~m->event & MOUSE_EVENT_UP) {
+ old_cx = data->cx;
+ old_cy = data->cy;
window_copy_update_cursor(wp, m->x, m->y);
if (window_copy_update_selection(wp, 1))
- window_copy_redraw_screen(wp);
+ window_copy_for_selection(wp, old_cx, old_cy);
return;
}
goto reset_mode;
redrawing the entire screen for every mouse coordinate update when it only
needed to update those lines where the selection might have changed.
This patch makes mouse selection buttery-smooth by only updating those
lines that need updating.
From aedcc3e976ad3df4037b479ac5b789160ab94a51 Mon Sep 17 00:00:00 2001
From: Michael Graczyk <***@mgraczyk.com>Date: Mon, 8 Dec 2014 16:57:49 -0800
Subject: [PATCH] Fix poor performance during mouse mode selection.
---
window-copy.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/window-copy.c b/window-copy.c
index f597332..e7fbd32 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -868,12 +868,37 @@ window_copy_key_numeric_prefix(struct window_pane
*wp, int key)
return (0);
}
+static void
+window_copy_for_selection(
+ struct window_pane *wp,
+ u_int old_x,
+ u_int old_y
+) {
+ struct window_copy_mode_data *data = wp->modedata;
+ const u_int new_y = data->cy;
+ u_int start, end, lines;
+
+ (void)old_x;
+ if (old_y <= new_y) {
+ start = old_y;
+ end = new_y;
+ } else {
+ start = new_y;
+ end = old_y;
+ }
+
+ lines = end - start + 1;
+ window_copy_redraw_lines(wp, start, lines);
+}
+
void
window_copy_mouse(struct window_pane *wp, struct session *sess,
struct mouse_event *m)
{
struct window_copy_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
+ u_int old_cx;
+ u_int old_cy;
u_int i;
if (m->x >= screen_size_x(s))
@@ -907,9 +932,11 @@ window_copy_mouse(struct window_pane *wp, struct
session *sess,
*/
if (s->mode & MODE_MOUSE_BUTTON) {
if (~m->event & MOUSE_EVENT_UP) {
+ old_cx = data->cx;
+ old_cy = data->cy;
window_copy_update_cursor(wp, m->x, m->y);
if (window_copy_update_selection(wp, 1))
- window_copy_redraw_screen(wp);
+ window_copy_for_selection(wp, old_cx, old_cy);
return;
}
goto reset_mode;
--
2.2.0.rc0.207.ga3a616c
2.2.0.rc0.207.ga3a616c