From 3bb02196dbac5f73545984c216adb93ea34d54e5 Mon Sep 17 00:00:00 2001 From: Richard Acayan Date: Sun, 4 Aug 2024 22:12:25 -0400 Subject: [PATCH] core: button: allow dragging to a text-only key part --- src/core/button.rs | 8 ++++---- src/core/layout.rs | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/core/button.rs b/src/core/button.rs index a759ec1..dfac21e 100644 --- a/src/core/button.rs +++ b/src/core/button.rs @@ -349,13 +349,13 @@ impl Button { fn update_pressed_part(press: &mut Press, key: &Key, angle: usize) { - if key.parts[ANGLE_PARTS[angle][0]].sym() != Keysym::NoSymbol { + if key.parts[ANGLE_PARTS[angle][0]].pressable() { press.part = ANGLE_PARTS[angle][0]; - } else if key.parts[ANGLE_PARTS[angle][1]].sym() != Keysym::NoSymbol { + } else if key.parts[ANGLE_PARTS[angle][1]].pressable() { press.part = ANGLE_PARTS[angle][1]; - } else if key.parts[ANGLE_PARTS[angle][2]].sym() != Keysym::NoSymbol { + } else if key.parts[ANGLE_PARTS[angle][2]].pressable() { press.part = ANGLE_PARTS[angle][2]; - } else if key.parts[ANGLE_PARTS[angle][3]].sym() != Keysym::NoSymbol { + } else if key.parts[ANGLE_PARTS[angle][3]].pressable() { press.part = ANGLE_PARTS[angle][3]; } } diff --git a/src/core/layout.rs b/src/core/layout.rs index 5f50d50..2bb7e31 100644 --- a/src/core/layout.rs +++ b/src/core/layout.rs @@ -402,6 +402,11 @@ impl Part { self.key_avail = self.val.0 != Keysym::NoSymbol && key_supp; } + pub fn pressable(&self) -> bool + { + self.text_avail || self.key_avail + } + pub fn modifier_id(&self) -> usize { match self.val.0 {