findWindowAt method
Returns the topmost window that contains the coordinates (gx, gy).
Implementation
Window? findWindowAt(int gx, int gy) {
// Sort windows by Z-Index descending (topmost first)
final sorted = List<Window>.from(windows)
..sort((a, b) => b.zIndex.compareTo(a.zIndex));
for (final win in sorted) {
final b = win.bounds;
if (gx >= b.x && gx < b.x + b.width && gy >= b.y && gy < b.y + b.height) {
return win;
}
}
return null;
}