From: Carl Hetherington Date: Tue, 7 Jun 2022 20:29:13 +0000 (+0200) Subject: Fix strange multi-selection behaviour on Linux (#2269). X-Git-Tag: v2.16.14~14 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=7fa7b39acdb940d8eafdf8b553525dae7c152084;hp=6b966acc4b9078989de82daf742b6569b749d0a0 Fix strange multi-selection behaviour on Linux (#2269). It seems that all of a sudden the behaviour of wxListCtrl's selection is strange (on Linux at least). If a list item is selected by some other action (e.g. selection in the timeline) and then you click another directly in the list, both are selected. This "fix" seems to work on Linux at least - also setting wxLIST_STATE_FOCUSED as well as wxLIST_STATE_SELECTED. I don't know why this works. --- diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 69dd72426..a7c9a4454 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -677,11 +677,7 @@ ContentPanel::set_selection (weak_ptr wc) { auto content = _film->content (); for (size_t i = 0; i < content.size(); ++i) { - if (content[i] == wc.lock ()) { - _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); - } else { - _content->SetItemState (i, 0, wxLIST_STATE_SELECTED); - } + set_selected_state(i, content[i] == wc.lock()); } } @@ -693,11 +689,7 @@ ContentPanel::set_selection (ContentList cl) auto content = _film->content (); for (size_t i = 0; i < content.size(); ++i) { - if (find(cl.begin(), cl.end(), content[i]) != cl.end()) { - _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); - } else { - _content->SetItemState (i, 0, wxLIST_STATE_SELECTED); - } + set_selected_state(i, find(cl.begin(), cl.end(), content[i]) != cl.end()); } _no_check_selection = false; @@ -783,7 +775,7 @@ ContentPanel::setup () _content->InsertItem (item); if (i.get() == selected_content) { - _content->SetItemState (t, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); + set_selected_state(t, true); } if (!valid || needs_kdm || needs_assets) { @@ -793,7 +785,7 @@ ContentPanel::setup () if (!selected_content && !content.empty ()) { /* Select the item of content if none was selected before */ - _content->SetItemState (0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); + set_selected_state(0, true); } setup_sensitivity (); @@ -861,6 +853,14 @@ ContentPanel::panels () const } +void +ContentPanel::set_selected_state(int item, bool state) +{ + _content->SetItemState(item, state ? wxLIST_STATE_SELECTED : 0, wxLIST_STATE_SELECTED); + _content->SetItemState(item, state ? wxLIST_STATE_FOCUSED : 0, wxLIST_STATE_FOCUSED); +} + + LimitedSplitter::LimitedSplitter (wxWindow* parent) : wxSplitterWindow (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_NOBORDER | wxSP_3DSASH | wxSP_LIVE_UPDATE) , _first_shown (false) diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index d6c81a8d2..a886b0217 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -128,6 +128,7 @@ private: void setup (); void setup_sensitivity (); + void set_selected_state(int item, bool state); void add_files (std::vector); std::list panels () const;