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.
This commit is contained in:
Daniel Eklöf 2019-11-30 11:59:47 +01:00
parent 0e5a69d869
commit edb78575c7
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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;
}