aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-01-04 12:00:59 -0800
committerPaul Gilbert2019-01-04 12:00:59 -0800
commit20191622f1e0dcec3b2b47332fc53fc0d0f9d7a8 (patch)
tree25a0585f12eb7ec2e2f3d04ec8845fd4b9b9ae3b /engines/glk
parent7394afbbc80be994cea0a83a91fadaf9aeccffdd (diff)
downloadscummvm-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.cpp6
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);