Use g_get_host_name for xauth generation and fix _XOPEN_SOURCE macro usage
Please see the discussion in !626 (merged). The reason of using g_get_host_name
here is that it is easier to use. It doesn't change the other gethostname
call because handling host name changes is required there.