1) a lot depends on the work environment DE WM it.d. - perhaps similar to the functionality there is implemented, or any opportunities to implement what you want.
2) pogovarit towards xwininfo xprop xrandr, wmctrl, xdotool
for example: xwininfoxwininfo -tree -root sends you all of your open Windows, their size and position on screen
using xrandr can determine the size and position of the screens.
knowing this information you can filter out the desired ID Windows.
and using wmctrl to control Windows
perhaps this can be done through only one wmctrl...