- for (std::list<Item*>::const_reverse_iterator i = root_children.rbegin(); i != root_children.rend(); ++i) {
- if (((sg = dynamic_cast<ScrollGroup*>(*i)) != 0) && sg->covers_window (in_window)) {
- break;
+ for (list<ScrollGroup*>::const_iterator s = scrollers.begin(); s != scrollers.end(); ++s) {
+
+ if ((*s)->covers_window (in_window)) {
+ sg = *s;
+
+ /* XXX January 22nd 2015: leaving this in place for now
+ * but I think it fixes a bug that really should be
+ * fixed in a different way (and will be) by my next
+ * commit. But it may still be relevant.
+ */
+
+ /* If scroll groups overlap, choose the one with the highest sensitivity,
+ that is, choose an HV scroll group over an H or V
+ only group.
+ */
+ if (!best_group || sg->sensitivity() > best_group->sensitivity()) {
+ best_group = sg;
+ if (sg->sensitivity() == (ScrollGroup::ScrollsVertically | ScrollGroup::ScrollsHorizontally)) {
+ /* Can't do any better than this. */
+ break;
+ }
+ }