Detect when cursor is interacting with an interface element of the 3D viewport

I have a modal operator running in the 3D viewport, and I would like to detect when the mouse is hovering over an interface element (A panel, the active toolbar on the right, a button on the top, etc…). Is it possible to do this currently?
The best I could do is getting the square regions inside the 3D Viewport area from context.screen.areas, then find the center region where there are no interface elements, however this method does not take into account the empty spaces in the other regions. (For example, the empty space below the active toolbar or a panel)

only way I’m aware of to accomplish something like this is to have a modal operator running in the background constantly monitoring mouse events and comparing them to the coordinates you’re interested in.