arsd.simpledisplay on macos

Adam Ruppe destructionator at gmail.com
Tue Nov 16 14:38:47 UTC 2021


On Tuesday, 16 November 2021 at 03:41:31 UTC, Ben Jones wrote:
> I'm trying to use Adam's simpledisplay on a mac with XQuartz 
> which is installed + running.  When I try to create a window, 
> it crashes when calling `XDisplayConnection.get()`.

Hmm, I have never actually seen that fail since the mac will 
start up the X server on demand.

Nevertheless, you might want to try a few things:

1) run xquartz separately to ensure it is up
2) set hte DISPLAY=:0 environment variable before starting the 
sdpy app
3) also perhaps try DISPLAY=127.0.0.1:0 in case it isn't 
configured for it


Also possible I bugged it since then though, since it dynamic 
loads the libs instead of static and I never actually tested that 
fully on mac. But I think if that was the case you'd get an abort 
instead of an exception; it wouldn't get to the connection failed 
step.

> r is there an example that seems to work with the native cocoa 
> version?  I'm only planning to use really basic functionality 
> (display an image and maybe capture some key presses)

I actually don't think the key press functions work anymore, but 
they are probably fairly easy to fix.

You have to build it without dub so you can pass 
-version=OSXCocoa to the compiler. Then some things at least 
should work.

But the Cocoa implementation was contributed to me back in like 
2012 and I've spent very little time on it since then. At one 
point last year, I did get its window working again at least but 
not much else. It is liable to throw NotYetImplementedExceptions 
and might have regressed since then too.

I have a mac vm i set up but it is a pain to use so I rarely 
bother....

> Also, Adam, if you have an idea of what needs to be done to get 
> native macos support working, I'm willing to try to give it a 
> shot.

So the existing code is an implementation of just the basic 
featureset built on extern(C) objc_msgSend calls. It is really 
ugly code and nothing I've added since 2012 works in there at all 
- anything more than the basic timer is not implemented, no file 
events, no opengl, no fonts. Even basic window methods probably 
won't work like maximize and show.

What I'd really like to do is to use dmd's beautiful 
extern(Objective-C) interface to make the code easier to use. I 
was kinda hoping those would be added to druntime like 
core.sys.windows but apparently not. ldc hasn't even implemented 
the feature at all :( (ive been considering porting it from dmd 
to ldc myself for like 2 years but it is super low priority since 
in the rare times i use a mac, im ok with the X server)

But yeah I don't know much about mac development and have a 
trillion other things to do.


More information about the Digitalmars-d-learn mailing list