From: <vl...@us...> - 2003-02-26 14:50:33
|
Update of /cvsroot/jungerl/jungerl/lib/ex11 In directory sc8-pr-cvs1:/tmp/cvs-serv19509 Added Files: Makefile README README.developers ex11.pub Log Message: Original 0.11 version by Torbjörn Törnkvist --- NEW FILE: Makefile --- ### -------------------------------------------------------------------- ### Created: 15 Feb 1999 by Tobbe to...@cs... ### ### $Id: Makefile,v 1.1 2003/02/26 14:50:25 vladdu Exp $ ### -------------------------------------------------------------------- # Change path if not the default compiler shall be used ERLC = erlc CVS_CHECKED_IN=/export/home/tobbe/bin/cvs_checked_in MODNAME = ex11 ERL_FILES = ex11.erl ex11_client.erl ex11_proto.erl ex11_utils.erl ex11_xauth.erl \ ex11_db.erl rcube.erl matrix44.erl JAM_FILES = $(ERL_FILES:.erl=.jam) BEAM_FILES = $(ERL_FILES:.erl=.beam) RELEASE_FILES = Makefile $(ERL_FILES) ex11.hrl ex11.pub README README.developers .SUFFIXES: .3 .html .sgml .jam .beam .hrl .erl .erl.jam: -$(ERLC) -W -b jam $< .erl.beam: -$(ERLC) -W -b beam $< all: jam beam jam: $(JAM_FILES) @echo " *** Compilation finished ***" beam: $(BEAM_FILES) @echo " *** Compilation finished ***" sgml: -sgml_transform -m 3 m.sgml -sgml_transform -html m.sgml @echo " *** SGML processing finished ***" clean: rm -f *.jam *.beam *sgmls* $(ERL_FILES): ex11.hrl release: $(CVS_CHECKED_IN) .. $(MODNAME) @echo "*** Specify a release tag name (M-N), e.g 2-5 : "; read tag; \ $(MAKE) do_release "FREEZE_TAG=$$tag" DOT_TAG=`echo $$tag | sed -e 's/-/\./'` do_release: cvs tag $(MODNAME)-$(FREEZE_TAG) @tar -cf $(MODNAME)-$(DOT_TAG).tar $(RELEASE_FILES) @mkdir $(MODNAME)-$(DOT_TAG) @mv $(MODNAME)-$(DOT_TAG).tar $(MODNAME)-$(DOT_TAG) @(cd $(MODNAME)-$(DOT_TAG); \ tar -xf $(MODNAME)-$(DOT_TAG).tar; rm -f $(MODNAME)-$(DOT_TAG).tar) @tar -cf $(MODNAME)-$(DOT_TAG).tar $(MODNAME)-$(DOT_TAG) @gzip $(MODNAME)-$(DOT_TAG).tar @mv $(MODNAME)-$(DOT_TAG).tar.gz $(MODNAME)-$(DOT_TAG).tgz @uuencode $(MODNAME)-$(DOT_TAG).tgz $(MODNAME)-$(DOT_TAG).tgz > $(MODNAME)-$(DOT_TAG).tgz.uu @rm -fr $(MODNAME)-$(DOT_TAG) @echo "*** Created file: $(MODNAME)-$(DOT_TAG).tgz" @echo "*** and file: $(MODNAME)-$(DOT_TAG).tgz.uu" --- NEW FILE: README --- *** Thu Mar 11 14:50:29 EST 1999 *** ex11-0-11.tgz =========== The package has changed name from x11 to ex11 to avoid any confusion. Also, a few changes has been done so that it now should be possible to run on Windows (assuming you have an X server). /Tobbe, to...@se... *** Tue Feb 23 11:10:00 EST 1999 *** x11-0-1.tgz =========== This is an Erlang-X11 binding, i.e an implementation of the X11 protocol in Erlang. At the time of this writing about 10 % of all requests/events has been implemented. The rest of the protocol would probably only take 2-3 weeks to implement since a complete framework exists already. Anyone interested in helping out with this should read README.developers. But before anything more are implemented I suggest that we wait for the new Erlang bit-syntax to be released. To compile both for JAM and BEAM, run: make or just: make jam make beam if you only are running one of the machines. Check out the code in rcube.erl for an example on how to use ex11. Run: rcube:start(HostName), where HostName is the name of the machine where your X-server is running (e.g rcube:start("campari"). Enjoy ! /Tobbe, to...@se... The following X11 requests are now implemented: =============================================== clear_area copy_area create_gc change_gc create_pixmap create_window get_geometry (and corresponding: get_geometry_reply ) map_window poly_fill_rectangle poly_line poly_segment Implemented events: =================== expose map_notify reparent_notify configure_notify event_nyi Error related records: ====================== refused_connection error The following records are used for holding values: ================================================== gc_values point rectangle segment win_values Implemented error messages: =========================== idchoice length request This is datastructures related to the display: ============================================== display format screen depth visual Holding Xauthority data: ======================== xauth Purely internal datastructures: =============================== xlib more Numerous constant definitions: ============================== See ex11.hrl --- NEW FILE: README.developers --- *** Fri Feb 19 15:21:11 EST 1999 *** If you are interested in helping out implementing the full X11 protocols + a toolkit on top of it, then let me know. Basically to add a new request, add a record for the request/event/error in the file ex11.hrl, then add the corresponding decoding and/or encoding routines in ex11_proto.erl. The examples below shows how to add a new event and a new request. Adding new requests are a little more complicated but looking at the existing code should be helpful. ------------------------------------------------------------------------ EXAMPLE: We add the MapNotify event 1. Edit ex11.hrl and locate the 'EVENT MESSAGES' part. 2. Under the 'Event Codes' heading, add: -define(EVENT_MAP_NOTIFY, 19). 3. Under the 'Event Records' heading, add: -record(map_notify, {seqno, event, window, override_redirect}). 4. Under the 'Event guards' heading, add: -define(IS_MAP_NOTIFY_EVENT(E), record(E,map_notify)). 5. Under the 'Decoding event messages', add a new function clause: decode_event([?EVENT_MAP_NOTIFY,_,S1,S0,E3,E2,E1,E0,W3,W2,W1,W0,V|D]) -> {_,Rest} = split_list(19,D), % 19 unused bytes E = #expose{seqno=i16(S1,S0), event=i32(W3,W2,W1,W0), window=i32(W3,W2,W1,W0), override_redirect=i16(V)}, {E,Rest}; 6. Write a test program which can receive the event. ------------------------------------------------------------------------ Example: We add the PolyLine request 1. Edit the file ex11.hrl, and go to the 'REQUEST MESSAGES' part. 2. Add a new request in alphabetic order among the other requests. Each request part may consists of a header, value-constants, sub-records (with guard tests), the record and finally its guard test. So, we add: %% --------- %% PolyLine %% Coordinate-mode values -define(POLY_COORDMODE_ORIGIN, 0). -define(POLY_COORDMODE_PREVIOUS, 1). -record(point, {x, y}). %% Guard test -define(IS_POINT(R), record(R,point)). -record(poly_line, {opcode = 65, coord_mode = ?POLY_COORDMODE_ORIGIN, len = 3, drawable, cid, points % list of point records }). %% Guard test -define(IS_POLY_LINE(R), record(R,poly_line)). Add default values (and comments) where suitable. 3. Edit the ex11_proto.erl file, and find the 'ENCODING REQUEST MESSAGES'. Read the comment about possible return values from the encode routine. 4. Add a suitable clause to enc/2: enc(X,Req) when ?IS_POLY_LINE(Req) -> poly_line(X,Req); 5. Implement the actual encode function (located in alphabetical order in the file): %% ---------------------- %% The Poly Line request poly_line(X,R) when R#poly_line.drawable =/= undefined, R#poly_line.gc =/= undefined, list(R#poly_line.points) -> PointsList = encode_points(R#poly_line.points), {ok, [R#poly_line.opcode, R#poly_line.coord_mode, i16(3 + length(PointsList)), i32(R#poly_line.drawable), i32(R#poly_line.gc), PointsList]}. encode_points([H|T]) when ?IS_POINT(H) -> [i16(H#point.x) ++ i16(H#point.y)|encode_points(T)]; encode_points([]) -> []. Add as many guards as possible. Don't perform any error checking int the encode function. An eventual crash will be 'caught' by the top-most function. 6. Write a little test program that tests the added request. ------------------------------------------------------------------------ Good luck, and send me your additions so that I can add them to the standard distribution of the Erlang- X11 binding. /Tobbe , tn...@ho... --- NEW FILE: ex11.pub --- (This appears to be a binary file; contents omitted.) |