From edb78575c7a7193e60d0f226143f75a29360290b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 30 Nov 2019 11:59:47 +0100 Subject: [PATCH] selection: forced selection requires keyboard focus Up the requirements for enabling "forced" selection (that is, allowing selections even though mouse tracking has been disabled). * Require keyboard focus (if we don't have it, then the shift-key isn't is for us) * Don't just require shift being pressed, but that all other modifiers are *not* pressed. --- selection.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/selection.c b/selection.c index 2839636a..8aa97e13 100644 --- a/selection.c +++ b/selection.c @@ -21,12 +21,23 @@ #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) +static bool +selection_forced(const struct terminal *term) +{ + const struct wayland *wayl = term->wl; + return wayl->focused == term && + wayl->kbd.shift && + !wayl->kbd.alt && + !wayl->kbd.ctrl && + !wayl->kbd.meta; +} + bool selection_enabled(const struct terminal *term) { return term->mouse_tracking == MOUSE_NONE || - term->wl->kbd.shift || + selection_forced(term) || term->is_searching; }