Xubuntu 16.04 ttyname failed Inappropriate ioctl for device

The ultimate cause is that Xubuntu clearly didn't expect anyone to perform a graphical login to the root account, so its default .profile file generates a spurious error in this situation. If you look at the last line of /root/.profile, you find:

mesg n || true

This is to prevent programs like talk from writing to your console. This is especially important if you logged in to root via a text session (su from xterm, ssh, etc.) since those messages can clutter up the screen.

The || true bit is to prevent the shell script from terminating if mesg should fail (as it is failing here), but that doesn't prevent it from generating error messages when it fails, which you are seeing.

The cause of the problem is that by putting the line in .profile, it runs every time bash is executed, even when it is run from a session without a tty device (like during the earliest parts of a graphical login), so you see the error. It's harmless, because mesg would be meaningless when run from a session without a TTY anyway, but the desktop doesn't know this and displays the message.

One solution (as a comment in a question you referenced said) is to change the line so it doesn't try to call mesg when there is no TTY:

tty -s && mesg n || true

This tells it to not try calling mesg when there is no TTY, but will still call it when there is a TTY (e.g. from an SSH login).