ComboBox: list: Fix expanding/collapsing tree rows

On clicking release, we call TreeView.get_path_at_pos() &, if we hit a
row, select it (if sensitive) & close the popup. But this alone does
not account for clicks on the expanders within the TreeView, so in
addition to expanding/collapsing, clicking them would close the list.

Check if the click is in the cell_area() & thus “excluding surrounding
borders and the tree expander area” but still including the background
(which TreeView.is_blank_at_pos() doesn’t); if TRUE, don’t select/close.

The popup doesn’t always resize enough… so there’s still breakage here.
The XXX comment on TreeView requests in list_position() may be relevant
to this. But at least this drags such CBs one step closer to adequacy:
expanding by mouse now works ~no worse~ than by keyboard already did.

https://bugzilla.gnome.org/show_bug.cgi?id=788505
This commit is contained in:
Daniel Boles
2017-10-04 18:54:43 +01:00
parent 628ff776d1
commit a20ff44b09

View File

@ -3129,6 +3129,9 @@ gtk_combo_box_list_button_released (GtkWidget *widget,
gboolean ret;
GtkTreePath *path = NULL;
GtkTreeIter iter;
GtkTreeViewColumn *column;
gint x;
GdkRectangle cell_area;
GtkComboBox *combo_box = GTK_COMBO_BOX (data);
GtkComboBoxPrivate *priv = combo_box->priv;
@ -3177,15 +3180,21 @@ gtk_combo_box_list_button_released (GtkWidget *widget,
return FALSE;
}
/* select something cool */
/* Determine which row was clicked and which column therein */
ret = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->tree_view),
event->x, event->y,
&path,
NULL, NULL, NULL);
&path, &column,
&x, NULL);
if (!ret)
return TRUE; /* clicked outside window? */
/* Dont select/close after clicking rows expander. cell_area excludes that */
gtk_tree_view_get_cell_area (GTK_TREE_VIEW (priv->tree_view),
path, column, &cell_area);
if (x < cell_area.x || x >= cell_area.x + cell_area.width)
return TRUE;
gtk_tree_model_get_iter (priv->model, &iter, path);
/* Use iter before popdown, as mis-users like GtkFileChooserButton alter the