If no screens, attempting to create a window results in clean exit

Asserting is only relevant for debug builds, and there were a couple
of other places that a segfault would typically occur before the assert
had a chance.

Change-Id: I1abc82eb3ecfa91050117fab1525f4cbd82ff486
Task-number: QTBUG-37876
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
XCB: use requested primary screen DISPLAY=:0.1 when possible

The current logic requires primary->output to not be specified, or
match the output number.  This fails when the output by that number
doesn't currently have a display attached, as non-connected outputs
are skipped.  This means setting the display to :0.1 for Qt5 will put
the window on :0.0 and it can't be moved to :0.1 after the fact.  The
solution is to pick the first output on the requested screen, then
override if an output exactly matches the primary output value.  That
way it will at least be on the requested screen.

Tested with Xephyr, ATI, and nVidia (proprietary driver), where the
nVidia had the primary output disconnected.

Task-number: QTBUG-15418
Change-Id: I7951dcef74cb135dc12a6e133a71c5852eae9778
Reviewed-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
NSScreen screens may be empty so add the main screen in that case

In some circumstances NSScreen screens can be empty yet there is still a
valid main screen so we prevent any problems arising by ensuring we work
with the main screen in that instance.

Task-number: QTBUG-37876
Change-Id: I5827009a9894eb8c1d4f5addc6c6f59e1c50c3d0
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>