Xpra: Ticket #391: osx shadow server improvements: mdns, keyboard support, etc

The OSX shadow server needs similar fixes to the win32 one (#389), namely:

Thu, 18 Jul 2013 07:50:34 GMT - Antoine Martin: description changed

Tue, 19 Aug 2014 04:06:23 GMT - Antoine Martin: milestone changed

Scheduling for 0.16

Fri, 23 Oct 2015 07:05:21 GMT - Antoine Martin: milestone changed


Thu, 21 Jan 2016 22:55:30 GMT - Antoine Martin: status changed

Running from a non GUI terminal bails out with this ugly message, which should be turned into a more friendly init check:

xpra main error:
Traceback (most recent call last):
  File "/Users/osx/Desktop/Xpra.app/Contents/Resources/lib/python/xpra/scripts/main.py", line 124, in main
    return run_mode(script_file, err, options, args, mode, defaults)
  File "/Users/osx/Desktop/Xpra.app/Contents/Resources/lib/python/xpra/scripts/main.py", line 919, in run_mode
    return run_server(error_cb, options, mode, script_file, args)
  File "/Users/osx/Desktop/Xpra.app/Contents/Resources/lib/python/xpra/scripts/server.py", line 927, in run_server
    app = ShadowServer()
  File "/Users/osx/Desktop/Xpra.app/Contents/Resources/lib/python/xpra/platform/darwin/shadow_server.py", line 48, in __init__
    raise Exception("cannot grab test screenshot - maybe you need to run this command whilst logged in via the UI")
Exception: cannot grab test screenshot - maybe you need to run this command whilst logged in via the UI

Thu, 21 Jan 2016 23:17:44 GMT - Antoine Martin:

Not sure if this is specific to OSX, but we should skip the stacktrace:

failed to create socket /var/tmp/502-Xpra/osx-2.local-0
Traceback (most recent call last):
  File "/Users/osx/Desktop/Xpra.app/Contents/Resources/lib/python/xpra/scripts/server.py", line 357, in setup_local_sockets
    sock, cleanup_socket = create_unix_domain_socket(sockpath, mmap_group, socket_permissions)
  File "/Users/osx/Desktop/Xpra.app/Contents/Resources/lib/python/xpra/scripts/server.py", line 231, in create_unix_domain_socket
  File "socket.pyc", line 228, in meth
error: [Errno 13] Permission denied
xpra initialization error:
 failed to create socket /var/tmp/502-Xpra/osx-2.local-0
closing tcp socket

Thu, 21 Jan 2016 23:53:07 GMT - Antoine Martin:

Some fixes:

New TODO: we should either ship the pybonjour mdns wrapper (as done with winswitch), or not bother trying avahi to avoid this message:

Warning: failed to load the mdns avahi publisher: No module named avahi
 either fix your installation or use the 'mdns=no' option

Mon, 28 Mar 2016 02:25:29 GMT - Antoine Martin:

Mon, 28 Mar 2016 03:15:16 GMT - Antoine Martin: description changed

Important fix to backport (keypresses cause a crash!) in r.

The CGRegisterScreenRefreshCallback is deprecated in 10.8, instead we're supposed to use the Streaming the Contents of a Display API, which can send us frames in BGRA, YUV420, ..

Using Quartz API, CGRegisterScreenRefreshCallback should be able to replace the timer, and look like this (adapted from the pyobjc tests):

from Quartz.CoreGraphics import CGRegisterScreenRefreshCallback, CGRect
myInfo = object()
callcount = [0]
def callbackRefresh(count, rects, info):
    assert info is myInfo
    assert isinstance(rects, tuple)
    assert isinstance(count, (int, long))
    for i in rects:
        assert isinstance(i, CGRect)
        callcount[0] += 1
err = CGRegisterScreenRefreshCallback(callbackRefresh, myInfo)
assert err==0
CGUnregisterScreenRefreshCallback(callbackRefresh, myInfo)

Also useful:

The keymapping is not implemented yet..

Mon, 28 Mar 2016 04:54:16 GMT - Antoine Martin:

The printing stuff is blocked by #641: we need the installer to add the cups backend script to the system.

Thu, 07 Apr 2016 11:32:45 GMT - Antoine Martin:

Note about selecting the audio device on OSX: osxaudiosrc/osaudiosink uses non-unique identifiers as device ID

Tue, 12 Apr 2016 12:20:37 GMT - Antoine Martin:

A lot of progress in #641 / r12376:

In order to support launching a remote shadow server via ssh (ie: xpra shadow ssh:OSXIP), we would need to run as an agent:

Maybe the agent can just sit there, listening for events and we just tell it what to run (ie: xpra shadow "$@"?) - which will then run from the correct context and be able to access the display server (avoiding the dreaded _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.): see #1169.

Sat, 16 Apr 2016 07:55:50 GMT - Antoine Martin: owner, status changed

@afarr: this is a FYI, feel free to close.

Sat, 16 Apr 2016 07:57:32 GMT - Antoine Martin: summary changed

Thu, 19 May 2016 23:06:32 GMT - alas: status changed; resolution set

Ok, thanks for info.

I actually gave it a shot, some luck with tcp, not so much with ssh... details of that failure in #1169.

This one looks like it's time it got closed.

Fri, 20 May 2016 06:04:33 GMT - Antoine Martin:

You must be doing something wrong. I've just re-tested against 10.6.x, 10.9.x and 10.10.x and it shadowed the existing display in all cases.

Thu, 22 Sep 2016 10:21:39 GMT - Antoine Martin:

Follow up: #1321, #1322

Sat, 23 Jan 2021 04:54:01 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/391