arsd.simpledisplay on macos

2021-11-15 Thread Ben Jones via Digitalmars-d-learn
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()`.  I'm just 
building dub and have added `"arsd-official:simpledisplay"` as a 
dependency.  Before I installed XQuartz, it wouldn't link because 
of the X related libs missing, so the XQuartz libs did seem to 
get installed to the right place.  The native cocoa 
implementation seemed less well tested than the X version so I 
haven't looked into that too much.


Any idea what's going wrong?  Or 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)


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.



```
object.Exception@../../../.dub/packages/arsd-official-10.3.8/arsd-official/simpledisplay.d(12578):
 Unable to open X display

../../../.dub/packages/arsd-official-10.3.8/arsd-official/simpledisplay.d:12578 
arsd.simpledisplay.Display* arsd.simpledisplay.XDisplayConnection.get() 
[0x10f49cc8e]
../../../.dub/packages/arsd-official-10.3.8/arsd-official/simpledisplay.d:13072 
void arsd.simpledisplay.SimpleWindow.impl.createWindow(int, int, 
immutable(char)[], in arsd.simpledisplay.OpenGlOptions, 
arsd.simpledisplay.SimpleWindow) [0x10f4882ec]
../../../.dub/packages/arsd-official-10.3.8/arsd-official/simpledisplay.d:1688 
arsd.simpledisplay.SimpleWindow arsd.simpledisplay.SimpleWindow.__ctor(int, 
int, immutable(char)[], arsd.simpledisplay.OpenGlOptions, 
arsd.simpledisplay.Resizability, arsd.simpledisplay.WindowTypes, int, 
arsd.simpledisplay.SimpleWindow) [0x10f486017]
source/app.d:869 _Dmain [0x10f47dff2]
Program exited with code 1```


Re: arsd.simpledisplay on macos

2021-11-16 Thread Adam Ruppe via Digitalmars-d-learn

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.


Re: arsd.simpledisplay on macos

2021-11-16 Thread Ben Jones via Digitalmars-d-learn

On Tuesday, 16 November 2021 at 14:38:47 UTC, Adam Ruppe wrote:


1) run xquartz separately to ensure it is up
2) set hte DISPLAY=:0 environment variable before starting the 
sdpy app


Adding DISPLAY:0 fixed it, thanks.  If I get time, I'll take a 
look at the objective C stuff, but that's a big if.


Re: arsd.simpledisplay on macos

2021-11-16 Thread Adam D Ruppe via Digitalmars-d-learn

On Tuesday, 16 November 2021 at 17:39:19 UTC, Ben Jones wrote:

Adding DISPLAY:0 fixed it, thanks.


ah, good to know! I probably set that as an automatic script on 
my old test computer and forgot about it. (It beeps at me now 
when I turn it on... apparently failed memory. alas.)


If I get time, I'll take a look at the objective C stuff, but 
that's a big if.


Email me if you do, I can help along. Hopefully I can catch up on 
some of my other projects over the next couple months too.