Fix detection of monitors connected to secondary GPU.

Fixes #4752