ANNOUNCE - graphics package

classic Classic list List threaded Threaded
87 messages Options
12345
Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Joe Williams-2

  ex11

  This is to announce that a pre-alpha release of ex11 is now available.

  ex11 is a 100% pure Erlang graphics package, which works only with
X-windows.

  ex11 talks *directly* to the X-server, no C is linked in.

  The ex11 release contains a library to talk to the server (This is
similar to XLib) and a widget set.

  The widget set is very powerful and very simple.

  ex11 with programming examples and screen shots can be found
at.
 
  http://www.sics.se/~joe/ex11

  At this stage I'd ask as many people as possible to test this release and
report any bugs or problems encountered in starting the system.

  Later I'd like volunteers to write new widgets and tools.

  I will support the widget infrastructure and the low level X library.

  Have fun

  /Joe

PS - Thanks to  Tobbe (who started this long ago) - and Vlad and Tony
who have also  hacked this at various times in the past.



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Vlad Dumitrescu-4
Excellent!!

I've tested it and it works now, even for me :-)

I'm glad you managed to implement the "widget = process" in what seems to be a
very nice way. I've been struggling with this issue for long, and couldn't find
enough inspiration and spare time at the same time.

best regards,
Vlad


Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Peter-Henry Mander-6

For those who may have difficulties with X11, do the following after make all:

xhost +localhost
erl -pa ./lib -pa ./widget.

Pete.

P.s. thanks Joe :-)


On Mon, 12 Jan 2004 13:39:38 +0100
"Vlad Dumitrescu" <vlad_dumitrescu> wrote:

> Excellent!!
>
> I've tested it and it works now, even for me :-)
>
> I'm glad you managed to implement the "widget = process" in what seems to be a
> very nice way. I've been struggling with this issue for long, and couldn't find
> enough inspiration and spare time at the same time.
>
> best regards,
> Vlad
>


--
Peter-Henry Mander
BSc hons. Comp Sci & Cyb
Software Engineer
Newport Networks Limited

Tel: + 44 (0) 1494 470 681



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Joe Williams-2
This should not be necessary - I'd really like to know those cases
where the start procedure fails.

If authentication fails it is because

     ex11_lib_driver:get_cookie

Has not been able to figure out what cookie to use

If authentication fails then give the commands
       
        > xauth
        list

To see what cookies you have, then stare at the code in  ex11_lib_driver
and ex11_lib_xauth to figure out what when wrong.

/Joe




On Mon, 12 Jan 2004, Peter-Henry Mander wrote:



>
> For those who may have difficulties with X11, do the following after make all:
>
> xhost +localhost
> erl -pa ./lib -pa ./widget.
>
> Pete.
>
> P.s. thanks Joe :-)
>
>
> On Mon, 12 Jan 2004 13:39:38 +0100
> "Vlad Dumitrescu" <vlad_dumitrescu> wrote:
>
> > Excellent!!
> >
> > I've tested it and it works now, even for me :-)
> >
> > I'm glad you managed to implement the "widget = process" in what seems to be a
> > very nice way. I've been struggling with this issue for long, and couldn't find
> > enough inspiration and spare time at the same time.
> >
> > best regards,
> > Vlad
> >
>
>
>



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Vlad Dumitrescu-4
In reply to this post by Joe Williams-2
>   I will support the widget infrastructure and the low level X library.

It's quite soon to ask this, but I wonder: do your plans include adding
functionality for X extensions? From what I saw in the code, it's not so easy to
extend in a modular way, but I may be jumping to conclusions.

What I had in mind was the Render extension, and also support for Xft. This goes
a bit beyond "Erlang only talks to X server", but I guess you would be also
interested in high quality output, TrueType fonts, antialiasing, transparency
and so on ;-)

regards,
Vlad


Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Joe Williams-2
On Mon, 12 Jan 2004, Vlad Dumitrescu wrote:

> >   I will support the widget infrastructure and the low level X library.
>
> It's quite soon to ask this, but I wonder: do your plans include adding
> functionality for X extensions? From what I saw in the code, it's not so easy to
> extend in a modular way, but I may be jumping to conclusions.
>
> What I had in mind was the Render extension, and also support for Xft. This goes
> a bit beyond "Erlang only talks to X server", but I guess you would be also
> interested in high quality output, TrueType fonts, antialiasing, transparency
> and so on ;-)
>

Yes indeed - but this is running before we can walk - text widgets
for variable width fonts etc is not entirely trivial.

  I'm beginnging  to wonder about extension  this - now do  I do alpha
blending for example??

/Joe



> regards,
> Vlad
>



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Vlad Dumitrescu-4
>   I'm beginnging  to wonder about extension  this - now do  I do alpha
> blending for example??

I used to have a link to documentation for most X protocols (core and
extensions) but I lost it. Maybe I will find it at home.

Otherwise, I think the best way to learn about Render is from the sources that
come with XFree86.

/Vlad


Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Joe Williams-2
In reply to this post by Vlad Dumitrescu-4
On Mon, 12 Jan 2004, Vlad Dumitrescu wrote:

> >   I will support the widget infrastructure and the low level X library.
>
> It's quite soon to ask this, but I wonder: do your plans include adding
> functionality for X extensions? From what I saw in the code, it's not so easy to
> extend in a modular way, but I may be jumping to conclusions.

On the contrary it is *very* easy - If I have not misunderstood.

In my code most commands boil down to things like (for example)


        xDo(Display, ePolyFillRectangle(DrawCursor, GC0,
                           [mkRectangle(0,0,?CursorWidth, ?CursorHt)])),

       
All names like

        ex11_lib:eXXXXX

Are primitive protocol messages.

To add support for (say) a rendering  extension one could make a new
protocol conversion module and write:

        xDo(Display, render:eSomeProtocolMessage(.....))

etc.

/Joe


>
> What I had in mind was the Render extension, and also support for Xft. This goes
> a bit beyond "Erlang only talks to X server", but I guess you would be also
> interested in high quality output, TrueType fonts, antialiasing, transparency
> and so on ;-)
>
> regards,
> Vlad
>



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Vlad Dumitrescu-4
> To add support for (say) a rendering  extension one could make a new
> protocol conversion module and write:
>
> xDo(Display, render:eSomeProtocolMessage(.....))
>
> etc.

Oh, yes! :-)

The replies are a little more tricky (i.e. one has to know which module to ask
to decode the data) but not much, and what I was thinking was to have the
extensions in mind so that it will be easy to add them after the core
functionality runs smoothly.

Just to check if I didn't miss this one: the image functionality isn't complete,
is it?

/Vlad


Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Joe Williams-2
On Mon, 12 Jan 2004, Vlad Dumitrescu wrote:

> > To add support for (say) a rendering  extension one could make a new
> > protocol conversion module and write:
> >
> > xDo(Display, render:eSomeProtocolMessage(.....))
> >
> > etc.
>
> Oh, yes! :-)
>
> The replies are a little more tricky (i.e. one has to know which module to ask
> to decode the data) but not much, and what I was thinking was to have the
> extensions in mind so that it will be easy to add them after the core
> functionality runs smoothly.

This is also easy :-)

Primitives end up by calling either req or call like this:


ePutImage(Draw, GC, Width, Ht, X, Y, Pad, Depth, Data) ->
    req(72, 2, <<Draw:32,GC:32,Width:16,Ht:16,X:16,Y:16,Pad:8,Depth:8,
                0:16,Data/binary>>).

PutImage has no reply


eQueryFont(Id) ->
    call(47, <<Id:32>>, eQueryFont).
                        **********

Query font has a reply. Here eQueryFont is the name of the parser to
be called when the command returns

Then when later the command returns this code gets called: ...

pReply1(eQueryFont, <<_:64,
                     MinBounds:12/binary,       % note the units of binary
                                                % are inbytes
                     _:32,
                     MaxBounds:12/binary,
                     _:32,
                     MinByte2:16,
                     MaxByte2:16,
                     DefaultChar:16,
                     NFontProps:16,
                     DrawDirection:8,
                     MinByte1:8,
                     MaxByte1:8,
                     AllCharsExist:8,
                     FontAscent:?INT16,
                     FontDescent:?INT16,
                     NCharInfos:32,
        ...



> Just to check if I didn't miss this one: the image functionality isn't complete,
> is it?

No. I have included the code to read and display a Jpeg - but I removed it
from the examples when I found that it didn't work on all machines.
You can try it if you like

The example only works if you have "true color" (I think its called this)

The code works if you have a modern graphics card but fails if you have to
map the colors. I have written the code for this but
still get weird colors on my machine at work.

/Joe



>
> /Vlad
>



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Peter-Henry Mander-6
In reply to this post by Joe Williams-2
Hi Joe,

In my case with SuSE 8.2 the .Xauthority list simply doesn't contain localhost. There's 127.0.0.2, and the actual hostname too, but not localhost. I'm not sure how or why it's become like this. Using xhost or xauth as a remedy does work.

It's no fault of ex11, although the demo does fail silently, there's no supervisor to catch the exit value of sw_driver:wConnect/2.

Pete.

On Mon, 12 Jan 2004 14:45:19 +0100 (CET)
Joe Armstrong <joe> wrote:

> This should not be necessary - I'd really like to know those cases
> where the start procedure fails.
>
> If authentication fails it is because
>
>      ex11_lib_driver:get_cookie
>
> Has not been able to figure out what cookie to use
>
> If authentication fails then give the commands
>
>         > xauth
> list
>
> To see what cookies you have, then stare at the code in  ex11_lib_driver
> and ex11_lib_xauth to figure out what when wrong.
>
> /Joe
>
>
>
>
> On Mon, 12 Jan 2004, Peter-Henry Mander wrote:
>
>
>
> >
> > For those who may have difficulties with X11, do the following after make all:
> >
> > xhost +localhost
> > erl -pa ./lib -pa ./widget.
> >
> > Pete.
> >
> > P.s. thanks Joe :-)
> >
> >
> > On Mon, 12 Jan 2004 13:39:38 +0100
> > "Vlad Dumitrescu" <vlad_dumitrescu> wrote:
> >
> > > Excellent!!
> > >
> > > I've tested it and it works now, even for me :-)
> > >
> > > I'm glad you managed to implement the "widget = process" in what seems to be a
> > > very nice way. I've been struggling with this issue for long, and couldn't find
> > > enough inspiration and spare time at the same time.
> > >
> > > best regards,
> > > Vlad
> > >
> >
> >
> >
>
>


--
Peter-Henry Mander
BSc hons. Comp Sci & Cyb
Software Engineer
Newport Networks Limited

Tel: + 44 (0) 1494 470 681



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Mikael Karlsson
In reply to this post by Joe Williams-2
Oh yes!
could I add some support for PDF like primitives to the wishlist, so
one could have an ErlGuten like interface.
See: http://www.cairographics.org/

There are actually two X11 libraries under jungerl:
ex11 and x11,  is  "ex11" the one to choose?

Regards Mikael.

m?ndag 12 januari 2004 15:26 skrev Joe Armstrong:

> On Mon, 12 Jan 2004, Vlad Dumitrescu wrote:
> > >   I will support the widget infrastructure and the low level X library.
> >
> > It's quite soon to ask this, but I wonder: do your plans include adding
> > functionality for X extensions? From what I saw in the code, it's not so
> > easy to extend in a modular way, but I may be jumping to conclusions.
> >
> > What I had in mind was the Render extension, and also support for Xft.
> > This goes a bit beyond "Erlang only talks to X server", but I guess you
> > would be also interested in high quality output, TrueType fonts,
> > antialiasing, transparency and so on ;-)
>
> Yes indeed - but this is running before we can walk - text widgets
> for variable width fonts etc is not entirely trivial.
>
>   I'm beginnging  to wonder about extension  this - now do  I do alpha
> blending for example??
>
> /Joe
>
> > regards,
> > Vlad



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Vlad Dumitrescu-4
From: "Mikael Karlsson" <mikael.karlsson>
>could I add some support for PDF like primitives to the wishlist, so
>one could have an ErlGuten like interface.
>See: http://www.cairographics.org/

And slightly related, on the To Do list ahould probably be a gs emulation
layer, so that existing graphics applications can be ported smoothly.

/Vlad


Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Vlad Dumitrescu-4
In reply to this post by Joe Williams-2
> > The replies are a little more tricky

> This is also easy :-)
> eQueryFont(Id) ->
>     call(47, <<Id:32>>, eQueryFont).
>         **********
> Then when later the command returns this code gets called: ...
>
> pReply1(eQueryFont, <<_:64,
>      MinBounds:12/binary,       % note the units of binary

Great! I couldn't figure that out in the short time I had.

/Vlad


Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Mats Cronqvist (ÄL2/EAB)
In reply to this post by Joe Williams-2
   thought i try ex11, but then i saw this;
"!! is an infix RPC operator. This needs a ONE LINE change to
erl_parse.yrl which makes a new version of erl_parse.erl"
   so only people that willing/able to rebuild erl_parse can try ex11. i
for one am not (willing, that is).
   but maybe a sed script or something can convert the code to erlang?

   mats


Reply | Threaded
Open this post in threaded view
|

Bang Bang

Joe Williams-2

Oh dear, sorry it's not *pure* erlang :-)

If the great maintainers add the following line to erl_parse.yrl

-----
expr_100 -> expr_150 '!' '!' expr_100: {call, line('$1'),
                                        {remote, line('$1'),
                                                {atom, line('$1'),sysd},
                                                {atom, line('$1'),rpc}},
                                        ['$1', '$4']}.
-----

then it would be standard Erlang :-)

Users would be free to define their own sysd:rpc

((possibly even better is to exapand this into ?MODULE:rpc/2))

The change is purely *local* - if you "make" everything a new versions of
erl_parse.erl{.beam} are put into the /widgets subdirectory.

    Pid !! X is just expanded into

        sysd:rpc(Pid, X).

    This make the code (IMHO) very pretty

    The code to swap the values in two entries, is thus ...

    Entry1 = Win !! mkEntry(....)
    Entry2 = Win !! mkEntry(...)
    Button = Win !! mkButton(....)
    ...
   
    Swap = fun(_) ->
              Str1 = Entry1 !! read,
              Str2 = Entry2 !! read,
              Entry1 ! {set, Str1},
              Entry2 ! {set, Str2}
           end,

    Button ! {onClick, Swap}

    ...

    To my mind this code is very clear and beautiful.

    We could even see at a glance that

        Entry !! read

    is a possible error (ie it should be)

        Var = Entry !! read

    ie why do an rpc and NOT store the value - if you *wanted* to
read the value but not get a return value you could write

        Entry ! read

     Instead ....

    Converting this to  rpc(Entry, read) etc is a lot uglier.

<<aside>>
 
It's a pity I had to change the parser to do this.

I can't do this with -parse_transform(...) because parse transform
only works with correctly parsed forms and !! is not a correct form.

What one needs is

        -token_transform(Mod).

Which transforms the input token stream prior to parsing.

/Joe

On Tue, 13 Jan 2004, mats cronqvist wrote:

>    thought i try ex11, but then i saw this;
> "!! is an infix RPC operator. This needs a ONE LINE change to
> erl_parse.yrl which makes a new version of erl_parse.erl"
>    so only people that willing/able to rebuild erl_parse can try ex11. i
> for one am not (willing, that is).
>    but maybe a sed script or something can convert the code to erlang?
>
>    mats
>



Reply | Threaded
Open this post in threaded view
|

X authentication ????

Joe Williams-2
In reply to this post by Peter-Henry Mander-6

As I understand things authentication works like this.

When you run an X app it reads the (local) .Xauthority file
and chooses the cookie of one of the entries in this file to
start a session with the server.

This is reasonably secure since a remote program cannot read the (local)
Xauthority file.

To allow remote hosts to run server sessions you can do one of two things:

        1) do xhosts+ on the servfer machine (dangerous)
        2) get the entry in the server Xauthority file into
  the  Xauthority file  on  the  client.  You  do  an "xauth  extract"
command on the server to get the cookie - send it to the client and do
an "xauth add" command on the client.

  2) Is the preferred method -  1) is unsafe since ANYBODY can connect
to your X server and do *anything* (like log all keystrokes)

So how does a local client figure out which Xauthority entry to use?

My code tries the following

   1) try "localhost"
   2) if that fails find the local host name
      and look that up
   3) give up

ie

host2cookie("localhost", Adata) ->
    case host2cookie1("localhost", Adata) of
        T = {true, Cookie} ->
            T;
        false ->
            case inet:gethostname() of
                {ok, Host} ->
                    case host2cookie1(Host, Adata) of
                        T = {true, Cookie} ->
                            T;
                        false ->
                            get_screen_zero(Adata)
                    end;
                _ ->
                    get_screen_zero(Adata)
            end
    end;

What next do I try 127.0.0.0 then 127.0.0.2 etc .....

Any ideas

/Joe



On Mon, 12 Jan 2004, Peter-Henry Mander wrote:

> Hi Joe,
>
> In my case with SuSE 8.2 the .Xauthority list simply doesn't contain localhost. There's 127.0.0.2, and the actual hostname too, but not localhost. I'm not sure how or why it's become like this. Using xhost or xauth as a remedy does work.
>
> It's no fault of ex11, although the demo does fail silently, there's no supervisor to catch the exit value of sw_driver:wConnect/2.
>
> Pete.
>
> On Mon, 12 Jan 2004 14:45:19 +0100 (CET)
> Joe Armstrong <joe> wrote:
>
> > This should not be necessary - I'd really like to know those cases
> > where the start procedure fails.
> >
> > If authentication fails it is because
> >
> >      ex11_lib_driver:get_cookie
> >
> > Has not been able to figure out what cookie to use
> >
> > If authentication fails then give the commands
> >
> >         > xauth
> > list
> >
> > To see what cookies you have, then stare at the code in  ex11_lib_driver
> > and ex11_lib_xauth to figure out what when wrong.
> >
> > /Joe
> >
> >
> >
> >
> > On Mon, 12 Jan 2004, Peter-Henry Mander wrote:
> >
> >
> >
> > >
> > > For those who may have difficulties with X11, do the following after make all:
> > >
> > > xhost +localhost
> > > erl -pa ./lib -pa ./widget.
> > >
> > > Pete.
> > >
> > > P.s. thanks Joe :-)
> > >
> > >
> > > On Mon, 12 Jan 2004 13:39:38 +0100
> > > "Vlad Dumitrescu" <vlad_dumitrescu> wrote:
> > >
> > > > Excellent!!
> > > >
> > > > I've tested it and it works now, even for me :-)
> > > >
> > > > I'm glad you managed to implement the "widget = process" in what seems to be a
> > > > very nice way. I've been struggling with this issue for long, and couldn't find
> > > > enough inspiration and spare time at the same time.
> > > >
> > > > best regards,
> > > > Vlad
> > > >
> > >
> > >
> > >
> >
> >
>
>
>



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Joe Williams-2
In reply to this post by Mikael Karlsson
On Mon, 12 Jan 2004, Mikael Karlsson wrote:

> Oh yes!
> could I add some support for PDF like primitives to the wishlist, so
> one could have an ErlGuten like interface.
> See: http://www.cairographics.org/


This is the plan ...

The next goal is to get support for anti-alised fonts and alpha blending
+ to get the kind of TCL/TK usability.

IMHO the ex11 graphics stuff is *much* easier to program than TCL since
you can *directly* hit the X protocol level.

In TCL/TK you have to *change languages* to do real tricky stuff
(ie you can no longer program in TCL to do tricky things but have to change to
C)


If you want to do tricky things in ex11 you can *stay* in Erlang - since
All levels can direcly communicate with the X server socket.


> There are actually two X11 libraries under jungerl:
> ex11 and x11,  is  "ex11" the one to choose?

Neither - the ex11 on http://www.sics.se/~joe/ex11 is derived from
the Jungerl but has now been significantly changed.

/Joe


>
> Regards Mikael.
>
> m?ndag 12 januari 2004 15:26 skrev Joe Armstrong:
> > On Mon, 12 Jan 2004, Vlad Dumitrescu wrote:
> > > >   I will support the widget infrastructure and the low level X library.
> > >
> > > It's quite soon to ask this, but I wonder: do your plans include adding
> > > functionality for X extensions? From what I saw in the code, it's not so
> > > easy to extend in a modular way, but I may be jumping to conclusions.
> > >
> > > What I had in mind was the Render extension, and also support for Xft.
> > > This goes a bit beyond "Erlang only talks to X server", but I guess you
> > > would be also interested in high quality output, TrueType fonts,
> > > antialiasing, transparency and so on ;-)
> >
> > Yes indeed - but this is running before we can walk - text widgets
> > for variable width fonts etc is not entirely trivial.
> >
> >   I'm beginnging  to wonder about extension  this - now do  I do alpha
> > blending for example??
> >
> > /Joe
> >
> > > regards,
> > > Vlad
>
>



Reply | Threaded
Open this post in threaded view
|

ANNOUNCE - graphics package

Vlad Dumitrescu-4
In reply to this post by Joe Williams-2
From: "Joe Armstrong" <joe>
> > The replies are a little more tricky
>
> This is also easy :-)

Ok, you got me into a corner here ;-)

The only remaining thing to pick on are events. It doesn't seem probable that
extensions would define own events, but it seems worth checking.

/Vlad



Reply | Threaded
Open this post in threaded view
|

X authentication ????

Joachim Durchholz
In reply to this post by Joe Williams-2
Joe Armstrong wrote:

> As I understand things authentication works like this.
>
> When you run an X app it reads the (local) .Xauthority file
> and chooses the cookie of one of the entries in this file to
> start a session with the server.
>
> This is reasonably secure since a remote program cannot read the (local)
> Xauthority file.

Security entirely depends on the authorization protocol in use. Some
send the cookies as plaintext.

> So how does a local client figure out which Xauthority entry to use?
>
> My code tries the following
>
>    1) try "localhost"
>    2) if that fails find the local host name
>       and look that up
>    3) give up

Wouldn't it be better to look up the X server name? I think that's how
authorization is supposed to work: the client specifies on what machine
the display should go, the server checks whether the client has proper
credentials.
(Part of the confusion may stem from the fact that the same records are
used by client and server.)

Typical usage:

User logs on to an X machine.
User starts a background task on a remote machine.
Background task is supposed to display a progress bar on user's terminal.

-> Background task is told the host name of user's machine, to use as an
X server for the display.

In an installation running a fixed set of software, the assignment of X
Servers to background processes may be part of a configuration. IOW the
background processes would get their machine names from a file or database.

Regards,
Jo
--
Currently looking for a new job.



12345