I use Automate to interact with a given app when it's in the foreground, however the "App in foreground" block doesn't always update correctly when using floating windows.
For testing, I use a simple automate task that does an infinite loop of "when foreground app (when changed)" and then report the new foreground package with a toast. The following situations should all produce a toast (foreground app context change), yet a few don't:
So, basically, use-case scenarios 5/ 6 are the only interactions which don't update the foreground up. In particular, it's annoying if I dismiss a floating window, it's still reported as the foreground app if I ask for it 10 minutes later (assuming I don't trigger any of the OK use-cases).
Alternatively, MIUI could always report the app displayed in the background as the foreground app, which would mean that, instead of fixing use-cases 5 & 6, use cases 4, 8, 10 shouldn't report a foreground app change. Since no other ROM has floating windows, I would guess there isn't an actual guideline on how this reporting should behave, but as it is, it's inconsistent.
I use MIUI 12.5 (21.3.24 BETA) on a Xiaomi Redmi Note 9S, but I suspect the bug is global to all versions.
For testing, I use a simple automate task that does an infinite loop of "when foreground app (when changed)" and then report the new foreground package with a toast. The following situations should all produce a toast (foreground app context change), yet a few don't:
- Opening an app from launcher- OK
- Switching apps from recents menu - OK
- Using quick-tile "floating windows" - OK (shows the previous app, the one now using most of the screen, as the active one)
- Click on a floating window - OK
- Click on the main window when a floating window had the focus - ERROR (no foreground app change reported)
- Dismiss (drag up from the bottom handle) a floating window - ERROR (same as above)
- Click on the main window when a floating window had the focus and the keyboard is shown, causing the keyboard to be hidden - OK
- Open a floating windows from the recents menu - OK
- Open launcher using Home button while there's a floating window - OK
- Open a floating window using the video-toolbox shortcut - OK
So, basically, use-case scenarios 5/ 6 are the only interactions which don't update the foreground up. In particular, it's annoying if I dismiss a floating window, it's still reported as the foreground app if I ask for it 10 minutes later (assuming I don't trigger any of the OK use-cases).
Alternatively, MIUI could always report the app displayed in the background as the foreground app, which would mean that, instead of fixing use-cases 5 & 6, use cases 4, 8, 10 shouldn't report a foreground app change. Since no other ROM has floating windows, I would guess there isn't an actual guideline on how this reporting should behave, but as it is, it's inconsistent.
I use MIUI 12.5 (21.3.24 BETA) on a Xiaomi Redmi Note 9S, but I suspect the bug is global to all versions.