After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 515435 - Xcb/Xlib bindings
Xcb/Xlib bindings
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
0.1.x
Other All
: Low enhancement
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks: 510336
 
 
Reported: 2008-02-09 16:33 UTC by Maciej (Matthew) Piechotka
Modified: 2009-05-07 20:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
xcb.vapi (5.41 KB, application/octet-stream)
2008-02-09 16:39 UTC, Maciej (Matthew) Piechotka
  Details
xcb_to_vapi.rb (6.00 KB, application/octet-stream)
2008-02-10 02:34 UTC, Maciej (Matthew) Piechotka
  Details
vala-client.xsl (15.75 KB, application/xslt+xml)
2008-02-11 21:01 UTC, Maciej (Matthew) Piechotka
  Details
xcb.head.vapi (5.53 KB, text/plain)
2008-02-12 11:52 UTC, Maciej (Matthew) Piechotka
  Details
vala-client.xsl (13.05 KB, application/xslt+xml)
2008-02-12 11:52 UTC, Maciej (Matthew) Piechotka
  Details
xcbproc.pl (2.50 KB, application/x-perl)
2008-02-12 11:55 UTC, Maciej (Matthew) Piechotka
  Details
xcb.patch (917.92 KB, patch)
2008-02-12 15:12 UTC, Maciej (Matthew) Piechotka
none Details | Review
xcb-diff.patch (196.27 KB, patch)
2008-02-13 14:19 UTC, Maciej (Matthew) Piechotka
none Details | Review
xcb-diff.patch (197.38 KB, patch)
2008-02-13 14:39 UTC, Maciej (Matthew) Piechotka
needs-work Details | Review

Description Maciej (Matthew) Piechotka 2008-02-09 16:33:41 UTC
To have possibility to direct communicate with X11. May be needed in various situations(XV programming for example).
Comment 1 Maciej (Matthew) Piechotka 2008-02-09 16:39:26 UTC
Created attachment 104786 [details]
xcb.vapi

First part - the not-autogenerated headers. Now I am going to revise my xslt to autogenerate the rest.
Comment 2 Maciej (Matthew) Piechotka 2008-02-10 02:34:49 UTC
Created attachment 104810 [details]
xcb_to_vapi.rb

Not perfect script. See inside for details (lot's TODO's).
If anybody want's to improve it please feel welcomed.
Comment 3 Maciej (Matthew) Piechotka 2008-02-11 21:01:30 UTC
Created attachment 104986 [details]
vala-client.xsl

This XSLT script should do it's work. However it is still missing some functions - from which most important changing names to C and Vala names.
I will finish it probably tomorrow. I probably extend by those functions libxslt (in C or in vala - however I can't find libxslt bindings - only xml)
Comment 4 Maciej (Matthew) Piechotka 2008-02-12 11:52:05 UTC
Created attachment 105033 [details]
xcb.head.vapi
Comment 5 Maciej (Matthew) Piechotka 2008-02-12 11:52:51 UTC
Created attachment 105034 [details]
vala-client.xsl
Comment 6 Maciej (Matthew) Piechotka 2008-02-12 11:55:27 UTC
Created attachment 105035 [details]
xcbproc.pl

Still imperfect - c:type do not work from some reasons.
Comment 7 Maciej (Matthew) Piechotka 2008-02-12 15:12:02 UTC
Created attachment 105060 [details] [review]
xcb.patch

Still imperfect patch (strange naming of fields, 1 as field name etc.) but it can be solved by hash in script or separate metadata file.
Comment 8 Maciej (Matthew) Piechotka 2008-02-13 14:19:34 UTC
Created attachment 105147 [details] [review]
xcb-diff.patch

XCB:XProto support seems to be reade.

Todo:
* Add extensions. Possibly in other files
* Possibly more OOP API:
Window w;
Connection conn;
//...
GetWindowAttributesCookie cookie;
cookie = w.getAttributes (conn);
Comment 9 Maciej (Matthew) Piechotka 2008-02-13 14:39:57 UTC
Created attachment 105150 [details] [review]
xcb-diff.patch

Addition of few XLib-integration functions
Comment 10 Maciej (Matthew) Piechotka 2008-02-14 14:53:24 UTC
I notice such problem:
If we map Xid's to classes in XCB we get multinheritance (for example Xcb.Window is Xcb.Drawable and Xcb.GLX.Drawable). Any idea how to solve it? 
Comment 11 Jürg Billeter 2008-02-14 14:58:06 UTC
Maybe one of the two or both should be an interface? (Might need some extensions in Vala)
Comment 12 Maciej (Matthew) Piechotka 2008-02-14 15:07:24 UTC
There is one problem (except lack of support to intefaces for non GObject) - 
parser should search the xidunions in all files. More elegant solution from xcb binding would be an autocasting union. But I imaging it is worst sin in high-level language ;)
Comment 13 Maciej (Matthew) Piechotka 2008-02-15 13:43:38 UTC
Other solution would be implicit cast. Olthought I imagine it can complicate vala internalities.
Comment 14 Maciej (Matthew) Piechotka 2008-02-24 13:19:36 UTC
(In reply to comment #13)
> Other solution would be implicit cast. Olthought I imagine it can complicate

s/Olthought/Althought/g; - sorry for error.
> vala internalities.
> 

I can start writing bindings if I know which constructions I am allow to use. 

List proposed as so far:
1. Interfaces
2. Unions
3. Implicit casts

Regards
Comment 15 Jürg Billeter 2008-03-01 17:04:49 UTC
Is it really an issue if users have to explicitly cast?

var glx = (Xcb.GLX.Drawable) some_other_drawable;
...

I've never really used xcb, so I don't know typical use cases, maybe code examples might help.
Comment 16 Maciej (Matthew) Piechotka 2008-03-01 19:19:51 UTC
Possibly not. 

Something like

Possibly quick'n'dirty syntax:
Xcb.GC gc;
Xcb.create_gc(conn, gc, (Xcb.Drawable) window,
              Xcb.GCMask.FOREGROUND, {screen.black_pixel});
Xcb.flush();
Xcb.poly_point (conn, Xcb.CoordMode.ORIGIN, (Xcb.Drawable)window, gc, 1, point);

Xcb.free_gc(conn, gc);

OO syntax:

Xcb.GC gc;
Xcb.Cookie cookie = gc.create (conn, (Xcb.Drawable) window,
                               Xcb.GCMask.FOREGROUND, {screen.black_pixel});
Xcb.flush ();
gc.poly_point (conn, Xcb.CoordMode.ORIGIN, (Xcb.Drawable)window, 1, point);
// Or:
// ((Xcb.Drawable)window).poly_point (conn, Xcb.CoordMode.ORIGIN, gc, 1, point);
gc.free (conn)
(c

My preffered syntax, however not possibly in simple binding of C library (implementation of some parts in Vala seems to be required) would be:
//Lazy object
Xcb.GC gc = Xcb.GC.create(conn, (Xcb.Drawable) window,
                          Xcb.GCMask.FOREGROUND, {screen.black_pixel});
// Force usage of gc
gc.poly_point (Xcb.CoordMode.ORIGIN, (Xcb.Drawable)window, 1, point);
// Or:
// window.poly_point (conn, Xcb.CoordMode.ORIGIN, gc, 1, point);
Comment 17 Maciej (Matthew) Piechotka 2008-03-01 19:23:07 UTC
1. Sorry it should be (in preferred syntex):
Xcb.GC gc = new Xcb.GC(conn, (Xcb.Drawable) window,
                       Xcb.GCMask.FOREGROUND, {screen.black_pixel});

2. Recently I suffer from lack of time. I hope I will have it in middle of march but more probable is that I will not have it before June.
Comment 18 Jürg Billeter 2009-05-07 19:50:38 UTC
commit bcdf1d1a3c077b19cb2c6d5d3454c6f06e79435e
Author: Jürg Billeter <j@bitron.ch>
Date:   Fri Apr 24 00:09:08 2009 +0200

    Add initial x11, xcb, and cairo-xcb bindings
    
    Fixes bug 515435.
Comment 19 Maciej (Matthew) Piechotka 2009-05-07 20:21:58 UTC
(In reply to comment #18)
> commit bcdf1d1a3c077b19cb2c6d5d3454c6f06e79435e
> Author: Jürg Billeter <j@bitron.ch>
> Date:   Fri Apr 24 00:09:08 2009 +0200
> 
>     Add initial x11, xcb, and cairo-xcb bindings
> 
>     Fixes bug 515435.
> 

Still many things are undone I guess.

1. The bindings can be generated from xcb-proto metadata files. I guess it is the 'proper' would be proper way.

2, Even hand written would not go around the problem of multiinheritance which is required for full xcb building.