diff options
author | Paul Gilbert | 2019-01-04 12:00:59 -0800 |
---|---|---|
committer | Paul Gilbert | 2019-01-04 12:00:59 -0800 |
commit | 20191622f1e0dcec3b2b47332fc53fc0d0f9d7a8 (patch) | |
tree | 25a0585f12eb7ec2e2f3d04ec8845fd4b9b9ae3b /engines/glk | |
parent | 7394afbbc80be994cea0a83a91fadaf9aeccffdd (diff) | |
download | scummvm-rg350-20191622f1e0dcec3b2b47332fc53fc0d0f9d7a8.tar.gz scummvm-rg350-20191622f1e0dcec3b2b47332fc53fc0d0f9d7a8.tar.bz2 scummvm-rg350-20191622f1e0dcec3b2b47332fc53fc0d0f9d7a8.zip |
GLK: Properly fix window clicking crash
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/window_pair.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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); |