From 20191622f1e0dcec3b2b47332fc53fc0d0f9d7a8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 4 Jan 2019 12:00:59 -0800 Subject: GLK: Properly fix window clicking crash --- engines/glk/window_pair.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/glk') diff --git a/engines/glk/window_pair.cpp b/engines/glk/window_pair.cpp index d571dc58e7..60d17957d0 100644 --- a/engines/glk/window_pair.cpp +++ b/engines/glk/window_pair.cpp @@ -245,8 +245,10 @@ void PairWindow::setArrangement(uint method, uint size, Window *keyWin) { } void PairWindow::click(const Point &newPos) { - for (int ctr = 0, idx = (_backward ? (int)_children.size() - 1 : 0); ctr < (int)_children.size(); - ++ctr, idx += (_backward ? -1 : 1)) { + // Note in case windows are partially overlapping, we want the top-most window to get the click. + // WHich is why we recurse in the opposite of the rendering direction (as the _backward flag) indicates + for (int ctr = 0, idx = (!_backward ? (int)_children.size() - 1 : 0); ctr < (int)_children.size(); + ++ctr, idx += (!_backward ? -1 : 1)) { Window *w = _children[idx]; if (w->_bbox.contains(newPos)) w->click(newPos); -- cgit v1.2.3