GNOME Bugzilla – Bug 788505
ComboBox in appears-as-list mode: Clicking a TreeView expander also selects that row/closes the popup
Last modified: 2017-10-05 00:36:34 UTC
LISTMODE=1 ./tests/testcombo Open the "What are you ?" ComboBox, hover over one of the expanders, see that it prelights, and click on it, expecting just to reveal the items within that node. The ComboBox closes, and the parent row whose expander you clicked is selected (if sensitive). Of course, clicking the expander should only cause its node to be expanded/collapsed, nothing else. Otherwise, tree models in list mode are next to useless.
This probably occurs because gtk_combo_box_list_button_released() doesn't bother to check whether gtk_tree_view_is_blank_at_pos() for the clicked position, which should return TRUE if an expander or other non-body area is clicked in that row.
but! Checking if blank_at_pos() means we also lose the ability to click on any non-text (etc.) parts of the row, which is a pain for usability. Thankfully, though, get_cell_area() "returns only the cell itself, excluding surrounding borders and the tree expander area." So, we can take the output x coordinate from the event and bail out if it's part of that excluded area. Clicks on the blank ("background") part of the row still work and select the row, but clicks on the expander are ignored as intended. ...but. This then reveals another problem: the popup doesn't resize to accomodate the newly revealed rows, so they can end up being unusable. I guess that'll require a reallocate or such. -appears-as-list: the ride never ends.
There's gtk_combo_box_list_popup_resize(), which seems like what's needed, but it doesn't seem to be doing the trick in this case. The gremlins. They're everywhere. This is most noticeable e.g. when expanding the middle row of the testcombo CB already mentioned above, but it can affect rows in other locations too. I'll probably push what I have, as it's an *improvement*. It makes clicking work, to the limited extent that expanding with the keyboard already did.
Created attachment 360931 [details] [review] 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.
Attachment 360931 [details] pushed as a20ff44 - ComboBox: list: Fix expanding/collapsing tree rows
Created attachment 360941 [details] [review] ComboBox: list: Don’t leak path on expand/collapse Determining that we clicked on the expander means that we had a valid path, so we still need to free that, even though we’re not selecting it.
Comment on attachment 360941 [details] [review] ComboBox: list: Don’t leak path on expand/collapse Attachment 360941 [details] pushed as 34cd1e3 - ComboBox: list: Don’t leak path on expand/collapse