Compare commits

..

1 Commits

Author SHA1 Message Date
Jules Aguillon
5d62cf7901 Avoid the selection being empty in selection mode
Emptying the selection with the spacebar slider puts the selection mode
in an unexpected state. This checks that this doesn't happen.

For example, moving the right end of the selection (by going right then
left in a single stroke) after it reached the left end will push it with
every steps to keep the selection of size 1.
2025-06-15 16:46:19 +02:00
2 changed files with 9 additions and 20 deletions

View File

@@ -78,11 +78,6 @@ public final class KeyEventHandler
case Compose_pending:
_autocap.stop();
break;
case Slider:
// Don't wait for the next key_up and move the cursor right away. This
// is called after the trigger distance have been travelled.
handle_slider(key.getSlider(), key.getSliderRepeat(), true);
break;
default: break;
}
}
@@ -104,7 +99,7 @@ public final class KeyEventHandler
case Modifier: break;
case Editing: handle_editing_key(key.getEditing()); break;
case Compose_pending: _recv.set_compose_pending(true); break;
case Slider: handle_slider(key.getSlider(), key.getSliderRepeat(), false); break;
case Slider: handle_slider(key.getSlider(), key.getSliderRepeat()); break;
case Macro: evaluate_macro(key.getMacro()); break;
}
update_meta_state(old_mods);
@@ -266,7 +261,7 @@ public final class KeyEventHandler
}
/** [r] might be negative, in which case the direction is reversed. */
void handle_slider(KeyValue.Slider s, int r, boolean key_down)
void handle_slider(KeyValue.Slider s, int r)
{
switch (s)
{
@@ -274,8 +269,8 @@ public final class KeyEventHandler
case Cursor_right: move_cursor(r); break;
case Cursor_up: move_cursor_vertical(-r); break;
case Cursor_down: move_cursor_vertical(r); break;
case Selection_cursor_left: move_cursor_sel(r, true, key_down); break;
case Selection_cursor_right: move_cursor_sel(r, false, key_down); break;
case Selection_cursor_left: move_cursor_sel(r, true); break;
case Selection_cursor_right: move_cursor_sel(r, false); break;
}
}
@@ -315,7 +310,7 @@ public final class KeyEventHandler
/** Move one of the two side of a selection. If [sel_left] is true, the left
position is moved, otherwise the right position is moved. */
void move_cursor_sel(int d, boolean sel_left, boolean key_down)
void move_cursor_sel(int d, boolean sel_left)
{
InputConnection conn = _recv.getCurrentInputConnection();
if (conn == null)
@@ -325,17 +320,10 @@ public final class KeyEventHandler
{
int sel_start = et.selectionStart;
int sel_end = et.selectionEnd;
// Reorder the selection when the slider has just been pressed. The
// selection might have been reversed if one end crossed the other end
// with a previous slider.
if (key_down && sel_start > sel_end)
{
sel_start = et.selectionEnd;
sel_end = et.selectionStart;
}
boolean modify_sel_start = sel_left == (sel_start <= sel_end);
do
{
if (sel_left)
if (modify_sel_start)
sel_start += d;
else
sel_end += d;

View File

@@ -306,6 +306,7 @@ public final class Pointers implements Handler.Callback
// Start sliding mode
if (new_value.getKind() == KeyValue.Kind.Slider)
startSliding(ptr, x, y, dx, dy, new_value);
_handler.onPointerDown(new_value, true);
}
}
@@ -468,7 +469,7 @@ public final class Pointers implements Handler.Callback
stopLongPress(ptr);
ptr.flags |= FLAG_P_SLIDING;
ptr.sliding = new Sliding(x, y, dirx, diry, kv.getSlider());
_handler.onPointerDown(kv, true);
_handler.onPointerHold(kv, ptr.modifiers);
}
/** Return the [FLAG_P_*] flags that correspond to pressing [kv]. */