[gtk: 6/11] listbase: Clear selection if rubberband selected an empty set
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 6/11] listbase: Clear selection if rubberband selected an empty set
- Date: Tue, 26 Jul 2022 01:08:09 +0000 (UTC)
commit 57c032e6ccd0e2ab65a47e1175f8e283dad65d85
Author: Corey Berla <corey berla me>
Date: Wed May 4 21:41:30 2022 -0700
listbase: Clear selection if rubberband selected an empty set
If rubberband returns an empty bitset the selection should be cleared
unless the shift or ctrl key is held
gtk/gtklistbase.c | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c
index b5d0d35a7a..86f408a562 100644
--- a/gtk/gtklistbase.c
+++ b/gtk/gtklistbase.c
@@ -1583,25 +1583,28 @@ gtk_list_base_stop_rubberband (GtkListBase *self,
return;
rubberband_selection = gtk_list_base_get_items_in_rect (self, &rect);
- if (gtk_bitset_is_empty (rubberband_selection))
- {
- gtk_bitset_unref (rubberband_selection);
- return;
- }
if (modify && extend) /* Ctrl + Shift */
{
- GtkBitset *current;
- guint min = gtk_bitset_get_minimum (rubberband_selection);
- guint max = gtk_bitset_get_maximum (rubberband_selection);
- /* toggle the rubberband, keep the rest */
- current = gtk_selection_model_get_selection_in_range (model, min, max - min + 1);
- selected = gtk_bitset_copy (current);
- gtk_bitset_unref (current);
- gtk_bitset_intersect (selected, rubberband_selection);
- gtk_bitset_difference (selected, rubberband_selection);
-
- mask = gtk_bitset_ref (rubberband_selection);
+ if (gtk_bitset_is_empty (rubberband_selection))
+ {
+ selected = gtk_bitset_ref (rubberband_selection);
+ mask = gtk_bitset_ref (rubberband_selection);
+ }
+ else
+ {
+ GtkBitset *current;
+ guint min = gtk_bitset_get_minimum (rubberband_selection);
+ guint max = gtk_bitset_get_maximum (rubberband_selection);
+ /* toggle the rubberband, keep the rest */
+ current = gtk_selection_model_get_selection_in_range (model, min, max - min + 1);
+ selected = gtk_bitset_copy (current);
+ gtk_bitset_unref (current);
+ gtk_bitset_intersect (selected, rubberband_selection);
+ gtk_bitset_difference (selected, rubberband_selection);
+
+ mask = gtk_bitset_ref (rubberband_selection);
+ }
}
else if (modify) /* Ctrl */
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]